summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-02-23 13:14:48 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-02-23 13:26:28 +0000
commit2328ddd0498969da47520d689858ce7bb036d858 (patch)
treebd8261b384c4860bdef84b71469937553731b2a6
parent152a43d9f7f29cb97629ec6141b48593a3c984f5 (diff)
Fix crashes when editing behavior script
Two issues that caused crashes when editing behavior script that was included in a presentation that was currently edited: 1) File system watcher triggers multiple change events for each save due to how Qt Creator saves files via a temp file. Sending the event to show progress dialog causes these pending events to be handled while we are handling the previous event. This caused a crash because we were operating on a reference to a member vector whose contents could change in response to file change event. Fixed this issue by making a copy of the vector instead of working with a reference. 2) Message box that is shown when parsing of the changed behavior script fails used currently active window as parent. In this case, the active window was the progress dialog. When progress dialog was destroyed, the destruction of the modal message box caused a crash. Fixed this issue by correctly parenting all message boxes to application main window instead of the active window. Task-number: QT3DS-1162 Change-Id: Ic6306fcc86910c225fa8ec3503a5d5b350d61e5c Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Antti Määttä <antti.maatta@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp2
-rw-r--r--src/Authoring/Studio/_Win/Workspace/Dialogs.cpp31
2 files changed, 17 insertions, 16 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index bd355c7a..3e02508f 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -4510,7 +4510,7 @@ public:
if (theFind == m_SourcePathInstanceMap.end())
continue;
- const TSlideInstanceList &theInstances(theFind->second);
+ const TSlideInstanceList theInstances(theFind->second);
if (theRecord.m_ModificationType != FileModificationType::Created) {
requestRender = true;
m_Doc.GetBufferCache().InvalidateBuffer(theRelativePath);
diff --git a/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp b/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp
index 4bceeecd..60f73ee3 100644
--- a/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp
+++ b/src/Authoring/Studio/_Win/Workspace/Dialogs.cpp
@@ -50,6 +50,7 @@
#include "IDocumentEditor.h"
#include "Qt3DSFileTools.h"
#include "ImportUtils.h"
+#include "MainFrm.h"
#include <QtWidgets/qcolordialog.h>
#include <QtWidgets/qfiledialog.h>
@@ -241,7 +242,7 @@ void CDialogs::DisplayAssetDeleteFailed()
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, theMessage, Qt3DSMessageBox::ICON_ERROR, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << theMessage;
}
@@ -273,7 +274,7 @@ void CDialogs::DisplayRefreshResourceFailed(const Q3DStudio::CString &inResource
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, theText, Qt3DSMessageBox::ICON_WARNING, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << theText;
}
@@ -351,7 +352,7 @@ void CDialogs::DisplayImportFailed(const QUrl &inURL, const QString &inDescripti
// Display the failed import resource message.
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, theMsgText, Qt3DSMessageBox::ICON_WARNING, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << theMsgText;
}
@@ -368,7 +369,7 @@ QString CDialogs::ConfirmRefreshModelFile(const QString &inFile)
true, true);
- return QFileDialog::getOpenFileName(qApp->activeWindow(), QObject::tr("Open"),
+ return QFileDialog::getOpenFileName(g_StudioApp.m_pMainWnd, QObject::tr("Open"),
inFile, theFileFilter, nullptr,
QFileDialog::DontUseNativeDialog);
}
@@ -377,7 +378,7 @@ QString CDialogs::ConfirmRefreshModelFile(const QString &inFile)
QList<QUrl> CDialogs::SelectAssets(QString &outPath,
Q3DStudio::DocumentEditorFileType::Enum assetType)
{
- QFileDialog fd(qApp->activeWindow());
+ QFileDialog fd(g_StudioApp.m_pMainWnd);
fd.setDirectory(outPath);
fd.setFileMode(QFileDialog::ExistingFiles);
fd.setOption(QFileDialog::DontUseNativeDialog, true);
@@ -429,7 +430,7 @@ void CDialogs::DisplayLoadingPresentationFailed(const Qt3DSFile &inPresentation,
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theErrorTitle, theErrorMessage, Qt3DSMessageBox::ICON_WARNING, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theErrorTitle << ": " << theErrorMessage;
}
@@ -449,7 +450,7 @@ void CDialogs::DisplaySavingPresentationFailed()
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theErrorTitle, theErrorMessage, Qt3DSMessageBox::ICON_WARNING, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theErrorTitle << ": " << theErrorMessage;
}
@@ -473,7 +474,7 @@ void CDialogs::DisplaySaveReadOnlyFailed(const Qt3DSFile &inSavedLocation)
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, theMsg, Qt3DSMessageBox::ICON_WARNING, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << theMsg;
}
@@ -500,7 +501,7 @@ CDialogs::DisplayMessageBox(const QString &inTitle, const QString &inText,
if (m_ShowGUI) {
theUserChoice =
Qt3DSMessageBox::Show(inTitle, inText, inIcon,
- inShowCancel, qApp->activeWindow());
+ inShowCancel, g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << inTitle << ": " << inText;
theUserChoice = Qt3DSMessageBox::MSGBX_OK;
@@ -767,7 +768,7 @@ void CDialogs::DisplayKnownErrorDialog(const QString &inErrorText)
QString theTitle = QObject::tr("Qt 3D Studio");
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, inErrorText, Qt3DSMessageBox::ICON_ERROR,
- false, qApp->activeWindow());
+ false, g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << inErrorText;
}
@@ -935,7 +936,7 @@ Qt3DSFile CDialogs::GetFileOpenChoice(const Q3DStudio::CString &inInitialDirecto
theImportFilter += " (*" + theFileExt + ")";
- QFileDialog theFileDlg(qApp->activeWindow(), QString(),
+ QFileDialog theFileDlg(g_StudioApp.m_pMainWnd, QString(),
(inInitialDirectory == Q3DStudio::CString("."))
? QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)
: inInitialDirectory.toQString(),
@@ -971,7 +972,7 @@ bool CDialogs::ConfirmRevert()
if (m_ShowGUI) {
theChoice = Qt3DSMessageBox::Show(theTitle, thePrompt, Qt3DSMessageBox::ICON_WARNING, true,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << thePrompt;
theChoice = Qt3DSMessageBox::MSGBX_OK;
@@ -996,7 +997,7 @@ void CDialogs::DisplayProgressScreen(const Q3DStudio::CString &inActionText,
const Q3DStudio::CString &inAdditionalText)
{
if (m_ShowGUI && !m_ProgressPalette) {
- m_ProgressPalette = new CProgressView(qApp->activeWindow());
+ m_ProgressPalette = new CProgressView(g_StudioApp.m_pMainWnd);
m_ProgressPalette->SetActionText(inActionText);
m_ProgressPalette->SetAdditionalText(inAdditionalText);
m_ProgressPalette->show();
@@ -1033,7 +1034,7 @@ void CDialogs::DisplayEnvironmentVariablesError(const Q3DStudio::CString &inErro
"\n{Variable} = Value\n");
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, theMessage, Qt3DSMessageBox::ICON_ERROR, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << theMessage;
}
@@ -1076,7 +1077,7 @@ void CDialogs::DisplayPasteFailed()
if (m_ShowGUI) {
Qt3DSMessageBox::Show(theTitle, theMessage, Qt3DSMessageBox::ICON_ERROR, false,
- qApp->activeWindow());
+ g_StudioApp.m_pMainWnd);
} else {
qCDebug(qt3ds::TRACE_INFO) << theTitle << ": " << theMessage;
}