Browse Source

Stop reloadModules crashing

Matt Clarkson 11 years ago
parent
commit
c2dacdfe4c

+ 17 - 1
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerMainWindow.cpp

@@ -323,7 +323,23 @@ void ctkCLModuleExplorerMainWindow::on_actionClear_Cache_triggered()
 //-----------------------------------------------------------------------------
 void ctkCLModuleExplorerMainWindow::on_actionReload_Modules_triggered()
 {
-  moduleManager.reloadModules();
+  this->setCursor(Qt::BusyCursor);
+
+  QList<QUrl> urls;
+
+  QList<ctkCmdLineModuleReference> moduleRefs = this->moduleManager.moduleReferences();
+  foreach (ctkCmdLineModuleReference ref, moduleRefs)
+  {
+    urls.push_back(ref.location());
+  }
+
+  QFuture<ctkCmdLineModuleReferenceResult> future = QtConcurrent::mapped(urls, ctkCmdLineModuleConcurrentRegister(&this->moduleManager));
+  future.waitForFinished();
+
+  this->unsetCursor();
+
+  ctkCmdLineModuleUtils::messageBoxModuleRegistration(future,
+                                                      this->moduleManager.validationMode());
 }
 
 

+ 0 - 12
Libs/CommandLineModules/Core/ctkCmdLineModuleManager.cpp

@@ -364,18 +364,6 @@ void ctkCmdLineModuleManager::clearCache()
 
 
 //----------------------------------------------------------------------------
-void ctkCmdLineModuleManager::reloadModules()
-{
-  foreach(const QUrl &location, d->LocationToRef.keys())
-  {
-    ctkCmdLineModuleReference ref = d->LocationToRef[location];
-    this->unregisterModule(ref);
-    this->registerModule(location);
-  }
-}
-
-
-//----------------------------------------------------------------------------
 ctkCmdLineModuleReference ctkCmdLineModuleManager::moduleReference(const QUrl &location) const
 {
   QMutexLocker lock(&d->Mutex);

+ 0 - 5
Libs/CommandLineModules/Core/ctkCmdLineModuleManager.h

@@ -168,11 +168,6 @@ public:
   void clearCache();
 
   /**
-   * @brief Reloads all currently valid modules, forcing the cache to be refreshed.
-   */
-  void reloadModules();
-
-  /**
    * @brief Returns a ctkCmdLineModuleReference object for the given URL.
    * @param location The location URL for which to get a module reference.
    * @return The module reference for the location or an invalid module reference