diff system/System.cpp @ 1179:6b1af0f05f06 pluginscan

Make use of, and warn for, the plugin checker for all types of plugin. Haven't yet resolved the question of how to install and find it.
author Chris Cannam
date Thu, 14 Apr 2016 14:03:18 +0100
parents bf05d9259dbc
children e5a1d815f331
line wrap: on
line diff
--- a/system/System.cpp	Thu Apr 14 12:12:04 2016 +0100
+++ b/system/System.cpp	Thu Apr 14 14:03:18 2016 +0100
@@ -325,77 +325,3 @@
 double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; }
 float princargf(float a) { return float(princarg(a)); }
 
-#ifndef _WIN32
-
-#include <unistd.h>
-#include <sys/wait.h>
-
-PluginLoadStatus
-TestPluginLoadability(QString soname, QString descriptorFn)
-{
-    //!!! This is POSIX only, no equivalent on Windows, where we'll
-    //!!! have to do something completely different
-
-    //!!! update -- this is a bad idea on POSIX systems as well, I
-    //!!! fear, because fork() generally doesn't mix with
-    //!!! multithreaded processes (it forks only one thread but any
-    //!!! locked mutexes from the other threads remain locked).
-    
-    pid_t pid = fork();
-
-    if (pid < 0) {
-        return UnknownPluginLoadStatus; // fork failed
-    }
-
-    if (pid == 0) { // the child process
-
-        cerr << "isPluginLibraryLoadable: About to try library \"" << soname << "\"" << endl;
-        
-        void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL);
-        if (!handle) {
-            cerr << "isPluginLibraryLoadable: Failed to open plugin library \""
-                 << soname << "\": " << dlerror() << "\n";
-            cerr << "exiting with status 1" << endl;
-            exit(1);
-        }
-
-        void *fn = DLSYM(handle, descriptorFn.toLocal8Bit().data());
-        if (!fn) {
-            cerr << "isPluginLibraryLoadable: Failed to find plugin descriptor function \"" << descriptorFn << "\" in library \"" << soname << "\": " << dlerror() << "\n";
-            exit(2);
-        }
-
-        cerr << "isPluginLibraryLoadable: Successfully loaded library \"" << soname << "\" and retrieved descriptor function" << endl;
-        
-        exit(0);
-
-    } else { // the parent process
-
-        int status = 0;
-
-        do {
-            cerr << "waiting for subprocess with pid " << pid << "..." << endl;
-            waitpid(pid, &status, 0);
-            cerr << "waited" << endl;
-        } while (WIFSTOPPED(status));
-
-        cerr << "and finished" << endl;
-
-        if (WIFEXITED(status)) {
-            switch (WEXITSTATUS(status)) {
-            case 0: return PluginLoadOK; // success
-            case 1: return PluginLoadFailedToLoadLibrary;
-            case 2: return PluginLoadFailedToFindDescriptor;
-            default: return PluginLoadFailedElsewhere;
-            }
-        }
-
-        if (WIFSIGNALED(status)) { 
-            return PluginLoadFailedElsewhere;
-        }
-
-        return UnknownPluginLoadStatus;
-    }
-}
-
-#endif