forked from qt-creator/qt-creator
QmlDesigner: Fix crash when example unavailable
Fix crash when opening an example that was there on startup, but got
removed during run time.
Task-number: QDS-15305
Change-Id: Idc425768d1f141d26eddd71e934e99beb4680b02
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
(cherry picked from commit 2c0ec81da4
)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
committed by
Henning Gründl
parent
84bdcae35a
commit
ed626849e8
@@ -75,6 +75,7 @@ Item {
|
||||
root.startDownload()
|
||||
} else if (downloadButton.alreadyDownloaded) {
|
||||
root.clicked() // open example
|
||||
extractor.probeTargetPath()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -260,6 +260,11 @@ void FileExtractor::extract()
|
||||
m_unarchiver->start();
|
||||
}
|
||||
|
||||
void FileExtractor::probeTargetPath()
|
||||
{
|
||||
emit targetFolderExistsChanged();
|
||||
}
|
||||
|
||||
void QmlDesigner::FileExtractor::removeTempTargetPath()
|
||||
{
|
||||
if (m_isTempTargetPath && m_targetPath.exists()) {
|
||||
|
@@ -59,6 +59,8 @@ public:
|
||||
Q_INVOKABLE void browse();
|
||||
Q_INVOKABLE void extract();
|
||||
|
||||
Q_INVOKABLE void probeTargetPath();
|
||||
|
||||
signals:
|
||||
void targetPathChanged();
|
||||
void detailedTextChanged();
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/imode.h>
|
||||
#include <coreplugin/messagebox.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
|
||||
#include "projectexplorer/target.h"
|
||||
@@ -290,14 +291,23 @@ public:
|
||||
QmlDesigner::QmlDesignerPlugin::emitUsageStatistics("exampleOpened:"
|
||||
+ exampleName);
|
||||
|
||||
const QString exampleFolder = examplePath + "/" + exampleName + "/";
|
||||
const FilePath exampleFilePath = FilePath::fromString(examplePath) / exampleName;
|
||||
|
||||
QString projectFile = exampleFolder + exampleName + ".qmlproject";
|
||||
FilePath projectFile = exampleFilePath / (exampleName + ".qmlproject");
|
||||
|
||||
if (!explicitQmlproject.isEmpty())
|
||||
projectFile = exampleFolder + explicitQmlproject;
|
||||
projectFile = exampleFilePath / explicitQmlproject;
|
||||
|
||||
ProjectExplorer::ProjectExplorerPlugin::openProjectWelcomePage(FilePath::fromString(projectFile));
|
||||
if (!projectFile.exists()) {
|
||||
Core::AsynchronousMessageBox::warning(
|
||||
tr("Could not open %1").arg(exampleName),
|
||||
tr("Project file %1 is missing. Try downloading the example again.")
|
||||
.arg(projectFile.nativePath()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ProjectExplorer::ProjectExplorerPlugin::openProjectWelcomePage(projectFile);
|
||||
}
|
||||
|
||||
Q_INVOKABLE void openExample(const QString &example,
|
||||
|
Reference in New Issue
Block a user