Commit b104b43f authored by hjk's avatar hjk

sessionmanager: replace signal sessionUnloaded() by aboutToUnloadSession()

sessionUnloaded was sometimes emitted when the session manager was in
an unsafe state (between delete m_file and  m_file = new ...) leading
to crashes when slots connected to the signal accessed the sessionmanager
again. This patch moves the signal emission before  delete m_file.

Reviewed-by: dt
parent a981c5c9
......@@ -611,8 +611,8 @@ CppModelManager::CppModelManager(QObject *parent)
connect(session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
this, SLOT(onAboutToRemoveProject(ProjectExplorer::Project *)));
connect(session, SIGNAL(sessionUnloaded()),
this, SLOT(onSessionUnloaded()));
connect(session, SIGNAL(aboutToUnloadSession()),
this, SLOT(onAboutToUnloadSession()));
qRegisterMetaType<CPlusPlus::Document::Ptr>("CPlusPlus::Document::Ptr");
......@@ -1078,7 +1078,7 @@ void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
GC();
}
void CppModelManager::onSessionUnloaded()
void CppModelManager::onAboutToUnloadSession()
{
if (m_core->progressManager()) {
m_core->progressManager()->cancelTasks(CppTools::Constants::TASK_INDEX);
......
......@@ -118,7 +118,7 @@ private Q_SLOTS:
// this should be executed in the GUI thread.
void onDocumentUpdated(CPlusPlus::Document::Ptr doc);
void onAboutToRemoveProject(ProjectExplorer::Project *project);
void onSessionUnloaded();
void onAboutToUnloadSession();
void onProjectAdded(ProjectExplorer::Project *project);
void postEditorUpdate();
void updateEditorSelections();
......
......@@ -1046,7 +1046,7 @@ void DebuggerManager::sessionLoaded()
loadSessionData();
}
void DebuggerManager::sessionUnloaded()
void DebuggerManager::aboutToUnloadSession()
{
cleanupViews();
if (m_engine)
......
......@@ -311,7 +311,7 @@ public slots:
void updateWatchData(const WatchData &data);
void sessionLoaded();
void sessionUnloaded();
void aboutToUnloadSession();
void aboutToSaveSession();
void assignValueInDebugger();
......
......@@ -871,8 +871,8 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
m_manager, SLOT(sessionLoaded()));
connect(sessionManager(), SIGNAL(aboutToSaveSession()),
m_manager, SLOT(aboutToSaveSession()));
connect(sessionManager(), SIGNAL(sessionUnloaded()),
m_manager, SLOT(sessionUnloaded()));
connect(sessionManager(), SIGNAL(aboutToUnloadSession()),
m_manager, SLOT(aboutToUnloadSession()));
// EditorManager
QObject *editorManager = core->editorManager();
......
......@@ -399,8 +399,8 @@ SessionManager::SessionManager(QObject *parent)
SessionManager::~SessionManager()
{
emit aboutToUnloadSession();
delete m_file;
emit sessionUnloaded();
}
......@@ -598,8 +598,8 @@ bool SessionManager::createImpl(const QString &fileName)
}
if (success) {
emit aboutToUnloadSession();
delete m_file;
emit sessionUnloaded();
m_file = new SessionFile;
m_file->setFileName(fileName);
setStartupProject(defaultStartupProject());
......@@ -633,9 +633,8 @@ bool SessionManager::loadImpl(const QString &fileName)
}
if (success) {
emit aboutToUnloadSession();
delete m_file;
m_file = 0;
emit sessionUnloaded();
m_file = new SessionFile;
if (!m_file->load(fileName)) {
QMessageBox::warning(0, tr("Error while restoring session"),
......
......@@ -159,8 +159,8 @@ signals:
void startupProjectChanged(ProjectExplorer::Project *project);
void sessionUnloaded();
void sessionLoaded();
void aboutToUnloadSession();
void aboutToSaveSession();
void dependencyChanged(ProjectExplorer::Project *a, ProjectExplorer::Project *b);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment