KDE/kdevelop/lib

Matt Rogers mattr at kde.org
Tue Feb 6 05:24:06 UTC 2007


SVN commit 630725 by mattr:

rename prepareForUnload to unload and call it directly instead of doing 
asynchronous plugin unloading. Gets rid of the error about the plugin controller
not being able to shut down in time.

If plugins want to do things before they're unloaded (save state, etc) they
must reimplement unload()

CCMAIL: kdevelop-devel at kdevelop.org



 M  +2 -2      interfaces/iplugin.cpp  
 M  +1 -8      interfaces/iplugin.h  
 M  +7 -53     shell/plugincontroller.cpp  
 M  +0 -8      shell/plugincontroller.h  


--- trunk/KDE/kdevelop/lib/interfaces/iplugin.cpp #630724:630725
@@ -80,9 +80,9 @@
     return false;
 }
 
-void IPlugin::prepareForUnload()
+void IPlugin::unload()
 {
-    emit readyToUnload( this );
+    //do nothing
 }
 
 KIconLoader *IPlugin::iconLoader() const
--- trunk/KDE/kdevelop/lib/interfaces/iplugin.h #630724:630725
@@ -220,7 +220,7 @@
     /**
      * Signal the plugin that it should cleanup since it will be unloaded soon.
      */
-    virtual void prepareForUnload();
+    virtual void unload();
 
     /**
      * Provides access to the global icon loader
@@ -246,13 +246,6 @@
      */
     void newIconLoader() const;
 
-Q_SIGNALS:
-    /**
-     * emitted when the plugin is ready to be unloaded by the plugin controller
-     * @param me The Plugin to unload. It should always be the this pointer
-     */
-    void readyToUnload( IPlugin* me );
-
 protected:
     QExtensionManager* extensionManager();
 
--- trunk/KDE/kdevelop/lib/shell/plugincontroller.cpp #630724:630725
@@ -106,6 +106,7 @@
         delete it.value();
     }
     delete m_manager;
+    qDeleteAll(d->plugins);
     delete d;
 }
 
@@ -140,7 +141,6 @@
 
     d->cleanupMode = PluginControllerPrivate::CleaningUp;
 
-
     // Ask all plugins to unload
     for ( PluginControllerPrivate::InfoToPluginMap::ConstIterator it = d->loadedPlugins.begin();
           it != d->loadedPlugins.end(); /* EMPTY */ )
@@ -152,18 +152,12 @@
         ++it;
 
         //Let the plugin do some stuff before unloading
-        current.value()->prepareForUnload();
+        IPlugin* plugin = current.value();
+        plugin->unload();
+        delete plugin;
     }
 
-    // When running under valgrind, don't enable the timer because it will almost
-    // certainly fire due to valgrind's much slower processing
-#if defined(HAVE_VALGRIND_H) && !defined(NDEBUG)
-        if ( RUNNING_ON_VALGRIND )
-            kDebug(9000) << k_funcinfo << "Running under valgrind, disabling plugin unload timeout guard" << endl;
-        else
-#endif
-
-    QTimer::singleShot( 3000, this, SLOT( cleanupTimeout() ) );
+    d->cleanupMode = PluginControllerPrivate::CleanupDone;
 }
 
 IPlugin* PluginController::loadPlugin( const QString& pluginName )
@@ -203,7 +197,8 @@
 {
     if( IPlugin *thePlugin = plugin( pluginId ) )
     {
-        thePlugin->prepareForUnload();
+        thePlugin->unload();
+        delete thePlugin;
     }
 }
 
@@ -291,8 +286,6 @@
 
         connect( plugin, SIGNAL( destroyed( QObject * ) ),
                  this, SLOT( pluginDestroyed( QObject * ) ) );
-        connect( plugin, SIGNAL( readyToUnload( IPlugin*) ),
-                 this, SLOT( pluginReadyForUnload( IPlugin* ) ) );
 
         kDebug(9000) << k_funcinfo << "Successfully loaded plugin '" << pluginId << "'" << endl;
 
@@ -367,47 +360,8 @@
             break;
         }
     }
-
-    if ( d->cleanupMode == PluginControllerPrivate::CleaningUp && d->loadedPlugins.isEmpty() )
-    {
-        // Use a timer to make sure any pending deleteLater() calls have
-        // been handled first
-        QTimer::singleShot( 0, this, SLOT( cleanupDone() ) );
-    }
 }
 
-void PluginController::pluginReadyForUnload( IPlugin* plugin )
-{
-    kDebug(9000) << k_funcinfo << pluginInfo( plugin )->pluginName() << " ready for unload" << endl;
-    delete plugin;
-}
-
-void PluginController::cleanupTimeout()
-{
-    // When we were already done the timer might still fire.
-    // Do nothing in that case.
-    if ( d->cleanupMode == PluginControllerPrivate::CleanupDone )
-        return;
-
-    QStringList remaining;
-    PluginControllerPrivate::InfoToPluginMap::ConstIterator it, itEnd;
-    it = d->loadedPlugins.begin();
-    itEnd = d->loadedPlugins.end();
-    for ( ; it != itEnd; ++it )
-        remaining.append( it.key()->pluginName() );
-
-    kWarning(9000) << k_funcinfo << "Some plugins didn't cleanup in time!" << endl
-            << "Remaining plugins: " << remaining << endl
-            << "Forcing cleanup now." << endl;
-
-    cleanupDone();
-}
-
-void PluginController::cleanupDone()
-{
-    d->cleanupMode = PluginControllerPrivate::CleanupDone;
-}
-
 ///@todo plugin load operation should be O(n)
 bool PluginController::checkForDependencies( KPluginInfo* info, QStringList& missing ) const
 {
--- trunk/KDE/kdevelop/lib/shell/plugincontroller.h #630724:630725
@@ -140,14 +140,6 @@
     ///A plugin has been destroyed. Cleanup our data structures
     void pluginDestroyed( QObject* );
 
-    ///A plugin is ready to unload. Unload it
-    void pluginReadyForUnload( IPlugin* );
-
-    ///Our timeout timer has expired
-    void cleanupTimeout();
-
-    void cleanupDone();
-
 private:
 
     /**




More information about the KDevelop-devel mailing list