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. Pick-to: qds/4.7 Task-number: QDS-15305 Change-Id: Idc425768d1f141d26eddd71e934e99beb4680b02 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
c93c84b25a
commit
2c0ec81da4
@@ -75,6 +75,7 @@ Item {
|
|||||||
root.startDownload()
|
root.startDownload()
|
||||||
} else if (downloadButton.alreadyDownloaded) {
|
} else if (downloadButton.alreadyDownloaded) {
|
||||||
root.clicked() // open example
|
root.clicked() // open example
|
||||||
|
extractor.probeTargetPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -259,6 +259,11 @@ void FileExtractor::extract()
|
|||||||
m_unarchiver->start();
|
m_unarchiver->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileExtractor::probeTargetPath()
|
||||||
|
{
|
||||||
|
emit targetFolderExistsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void QmlDesigner::FileExtractor::removeTempTargetPath()
|
void QmlDesigner::FileExtractor::removeTempTargetPath()
|
||||||
{
|
{
|
||||||
if (m_isTempTargetPath && m_targetPath.exists()) {
|
if (m_isTempTargetPath && m_targetPath.exists()) {
|
||||||
|
@@ -59,6 +59,8 @@ public:
|
|||||||
Q_INVOKABLE void browse();
|
Q_INVOKABLE void browse();
|
||||||
Q_INVOKABLE void extract();
|
Q_INVOKABLE void extract();
|
||||||
|
|
||||||
|
Q_INVOKABLE void probeTargetPath();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void targetPathChanged();
|
void targetPathChanged();
|
||||||
void detailedTextChanged();
|
void detailedTextChanged();
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/imode.h>
|
#include <coreplugin/imode.h>
|
||||||
|
#include <coreplugin/messagebox.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
#include <projectexplorer/devicesupport/devicekitaspects.h>
|
#include <projectexplorer/devicesupport/devicekitaspects.h>
|
||||||
@@ -290,14 +291,23 @@ public:
|
|||||||
QmlDesigner::QmlDesignerPlugin::emitUsageStatistics("exampleOpened:"
|
QmlDesigner::QmlDesignerPlugin::emitUsageStatistics("exampleOpened:"
|
||||||
+ exampleName);
|
+ 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())
|
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,
|
Q_INVOKABLE void openExample(const QString &example,
|
||||||
|
Reference in New Issue
Block a user