summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-06-13 15:23:04 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-06-18 12:09:40 +0000
commit737c8d8b3d887d788552875d77739e5a599826e8 (patch)
tree74c4d9d0b214fb90a6d1bfa006a1b16d448bf167
parent680c6a2fef979bd7eaea0834ec909b1147cf12d4 (diff)
Fix editor crash at shutdown
When building against Qt 5.11.1, deleting the CMainFrame is apparently no longer doable while handling the CMainFrame::closeEvent, as it will queue a close event for the underlying QWindow. We need to perform shutdown asynchronously from the close event. Task-number: QT3DS-1922 Change-Id: I6e056fad60aa6d91eef8dcd4c147c6b47d80b220 Reviewed-by: Antti Määttä <antti.maatta@qt.io>
-rw-r--r--src/Authoring/Studio/Application/MsgRouter.cpp5
-rw-r--r--src/Authoring/Studio/Application/MsgRouter.h1
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp12
-rw-r--r--src/Authoring/Studio/Application/StudioApp.h2
-rw-r--r--src/Authoring/Studio/MainFrm.cpp2
5 files changed, 17 insertions, 5 deletions
diff --git a/src/Authoring/Studio/Application/MsgRouter.cpp b/src/Authoring/Studio/Application/MsgRouter.cpp
index 4ce57cc8..d5e834c4 100644
--- a/src/Authoring/Studio/Application/MsgRouter.cpp
+++ b/src/Authoring/Studio/Application/MsgRouter.cpp
@@ -72,6 +72,11 @@ CMsgRouter *CMsgRouter::GetInstance()
return static_theInstance.get();
}
+void CMsgRouter::blockMessages()
+{
+ qApp->removeEventFilter(this);
+}
+
//==============================================================================
/**
* Send a command to be executed asynchronously.
diff --git a/src/Authoring/Studio/Application/MsgRouter.h b/src/Authoring/Studio/Application/MsgRouter.h
index 78dbf4f6..efd7e6be 100644
--- a/src/Authoring/Studio/Application/MsgRouter.h
+++ b/src/Authoring/Studio/Application/MsgRouter.h
@@ -99,6 +99,7 @@ public:
virtual ~CMsgRouter();
void SendCommand(CCmd *inCommand, CCore *inCore);
+ void blockMessages();
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index fd0f9f76..5e021f86 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -273,6 +273,8 @@ void CStudioApp::performShutdown()
// Get rid of the temp files
Qt3DSFile::ClearCurrentTempCache();
+ CMsgRouter::GetInstance()->blockMessages();
+
qApp->exit();
}
@@ -795,9 +797,13 @@ void CStudioApp::handleMessageReceived(const QString &message, QObject *socket)
QLocalSocket *lsocket = qobject_cast<QLocalSocket *>(socket);
if (lsocket) {
// Another studio instance wants to know if specified presentation is open on this one
- QFileInfo checkFile(message.mid(activePresentationQuery.size()));
- QFileInfo openFile(m_core->GetDoc()->GetDocumentPath().GetAbsolutePath().toQString());
- if (checkFile == openFile) {
+ QString checkPath(message.mid(activePresentationQuery.size()));
+ QFileInfo checkFile(checkPath);
+ QString docPath;
+ if (m_core)
+ docPath = m_core->GetDoc()->GetDocumentPath().GetAbsolutePath().toQString();
+ QFileInfo openFile(docPath);
+ if (!checkPath.isEmpty() && checkFile == openFile) {
lsocket->write(SharedTools::QtLocalPeer::acceptReply(),
SharedTools::QtLocalPeer::acceptReply().size());
// Since we accept active presentation query, it means the querying instance will
diff --git a/src/Authoring/Studio/Application/StudioApp.h b/src/Authoring/Studio/Application/StudioApp.h
index d3f77db2..d5df1d9b 100644
--- a/src/Authoring/Studio/Application/StudioApp.h
+++ b/src/Authoring/Studio/Application/StudioApp.h
@@ -87,7 +87,6 @@ public:
void onAppAbout();
- void performShutdown();
Q3DStudio::IDirectoryWatchingSystem &getDirectoryWatchingSystem();
void setupTimer(long inMessageId, QWidget *inWnd);
Q3DStudio::ITickTock &getTickTock();
@@ -99,6 +98,7 @@ public:
public Q_SLOTS:
void handleMessageReceived(const QString &message, QObject *socket);
+ void performShutdown();
protected:
bool runApplication();
diff --git a/src/Authoring/Studio/MainFrm.cpp b/src/Authoring/Studio/MainFrm.cpp
index d056bff7..bd9df0b5 100644
--- a/src/Authoring/Studio/MainFrm.cpp
+++ b/src/Authoring/Studio/MainFrm.cpp
@@ -809,7 +809,7 @@ void CMainFrame::closeEvent(QCloseEvent *event)
}
// Tell the app to shutdown, do it here so it does not rely on static destructor.
- g_StudioApp.performShutdown();
+ QTimer::singleShot(0, &g_StudioApp, &CStudioApp::performShutdown);
}
//==============================================================================