Explorar el Código

Do not delete the plugin activator.

After stopping a plug-in, the activator might still be used by someone.

Unloading the plugin's shared library is not straight forward. See
the inline comments.
Sascha Zelzer hace 13 años
padre
commit
bf43a3087c
Se han modificado 1 ficheros con 9 adiciones y 3 borrados
  1. 9 3
      Libs/PluginFramework/ctkPluginPrivate.cpp

+ 9 - 3
Libs/PluginFramework/ctkPluginPrivate.cpp

@@ -405,7 +405,6 @@ const ctkRuntimeException* ctkPluginPrivate::stop0()
 //----------------------------------------------------------------------------
 const ctkRuntimeException* ctkPluginPrivate::stop1()
 {
-  ctkPluginActivator* activator = 0;
   const ctkRuntimeException* res = 0;
 
   //6:
@@ -434,7 +433,6 @@ const ctkRuntimeException* ctkPluginPrivate::stop1()
       res = new ctkPluginException("ctkPlugin::stop: PluginActivator stop failed",
                                               ctkPluginException::ACTIVATOR_ERROR, &e);
     }
-    activator = pluginActivator;
     pluginActivator = 0;
   }
 
@@ -454,7 +452,15 @@ const ctkRuntimeException* ctkPluginPrivate::stop1()
     }
   }
 
-  delete activator;
+  // This would unload the shared library and delete the activator if
+  // there are no dependencies. However, objects from the plug-in might
+  // have been created via C-function symbol lookups. Hence we cannot
+  // safely unload the DLL. Maybe implement a in-DLL counter later
+  // (http://stackoverflow.com/questions/460809/c-dll-unloading-issue and
+  // http://boost.2283326.n4.nabble.com/shared-ptr-A-smarter-smart-pointer-proposal-for-dynamic-libraries-td2649749.html).
+  // The activator itself will be delete during program termination
+  // (by the QPluginLoader instance).
+  //pluginLoader.unload();
 
   return res;
 }