~ubuntu-branches/debian/jessie/stellarium/jessie

« back to all changes in this revision

Viewing changes to src/core/StelModuleMgr.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2009-03-13 20:07:22 UTC
  • mfrom: (1.1.8 upstream)
  • mto: (11.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20090313200722-gbgujsmzsa8a02ty
Import upstream version 0.10.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        // Initialize empty call lists for each possible actions
37
37
        callOrders[StelModule::ActionDraw]=QList<StelModule*>();
38
38
        callOrders[StelModule::ActionUpdate]=QList<StelModule*>();
39
 
        callOrders[StelModule::ActionHangleMouseClicks]=QList<StelModule*>();
 
39
        callOrders[StelModule::ActionHandleMouseClicks]=QList<StelModule*>();
40
40
        callOrders[StelModule::ActionHandleMouseMoves]=QList<StelModule*>();
41
41
        callOrders[StelModule::ActionHandleKeys]=QList<StelModule*>();
42
42
        callingListsToRegenerate = false;
59
59
*************************************************************************/
60
60
void StelModuleMgr::registerModule(StelModule* m, bool fgenerateCallingLists)
61
61
{
62
 
        if (modules.find(m->objectName()) != modules.end())
 
62
        QString name = m->objectName();
 
63
        if (modules.find(name) != modules.end())
63
64
        {               
64
 
                qWarning() << "Module \"" << m->objectName() << "\" is already loaded.";
 
65
                qWarning() << "Module \"" << name << "\" is already loaded.";
65
66
                return;
66
67
        }
67
 
        modules.insert(m->objectName(), m);
 
68
        modules.insert(name, m);
68
69
        m->setParent(this);
69
70
        
70
71
        if (fgenerateCallingLists)
74
75
/*************************************************************************
75
76
 Unregister and delete a StelModule.
76
77
*************************************************************************/
77
 
void StelModuleMgr::unloadModule(const QString& moduleID)
 
78
void StelModuleMgr::unloadModule(const QString& moduleID, bool alsoDelete)
78
79
{
79
80
        StelModule* m = getModule(moduleID);
80
81
        if (!m)
83
84
                return;
84
85
        }
85
86
        modules.remove(moduleID);
 
87
        m->setParent(NULL);
86
88
        callingListsToRegenerate = true;
87
 
        m->deleteLater();
 
89
        if (alsoDelete)
 
90
                m->deleteLater();
88
91
}
89
92
 
90
93
/*************************************************************************
121
124
        {
122
125
                moduleFullPath = StelApp::getInstance().getFileMgr().findFile(moduleFullPath, StelFileMgr::File);
123
126
        }
124
 
        catch (std::exception& e)
 
127
        catch (std::runtime_error& e)
125
128
        {
126
129
                qWarning() << "ERROR while locating plugin path: " << e.what();
127
130
        }
167
170
                const PluginDescriptor& d = i.previous();
168
171
                if (d.loadAtStartup==false)
169
172
                        continue;
170
 
                unloadModule(d.key);
 
173
                unloadModule(d.key, true);
171
174
                qDebug() << "Unloaded plugin " << d.key << ".";
172
175
        }
173
176
}
207
210
        {
208
211
                moduleDirs = fileMan.listContents("modules",StelFileMgr::Directory);
209
212
        }
210
 
        catch(std::exception& e)
 
213
        catch(std::runtime_error& e)
211
214
        {
212
215
                qWarning() << "ERROR while trying list list modules:" << e.what();      
213
216
        }
226
229
                        mDesc.loadAtStartup = pd.value("module/load_at_startup").toBool();
227
230
                        result.push_back(mDesc);
228
231
                }
229
 
                catch (std::exception& e)
 
232
                catch (std::runtime_error& e)
230
233
                {
231
234
                        qWarning() << "WARNING: unable to successfully read module.ini file from plugin " << *dir;
232
235
                }