forked from qt-creator/qt-creator
QmlProjectManager: Avoid use of RunControl::runConfiguration()
The RunConfiguration might change and even die after the runcontrol starts. Change-Id: I628f3ae26c21fb41388b6104497ce5a6a6704c8a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -449,11 +449,6 @@ void QmlPreviewPluginPrivate::setDirty()
|
||||
void QmlPreviewPluginPrivate::addPreview(ProjectExplorer::RunControl *preview)
|
||||
{
|
||||
m_runningPreviews.append(preview);
|
||||
if (auto multiLanguageAspect =
|
||||
preview->runConfiguration()->aspect<QmlProjectManager::QmlMultiLanguageAspect>()) {
|
||||
connect(multiLanguageAspect, &QmlProjectManager::QmlMultiLanguageAspect::changed,
|
||||
preview, &ProjectExplorer::RunControl::initiateStop);
|
||||
}
|
||||
emit q->runningPreviewsChanged(m_runningPreviews);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/runcontrol.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -81,6 +82,16 @@ QmlMultiLanguageAspect::QmlMultiLanguageAspect(ProjectExplorer::Target *target)
|
||||
setDefaultValue(!databaseFilePath().isEmpty());
|
||||
QVariantMap getDefaultValues;
|
||||
fromMap(getDefaultValues);
|
||||
|
||||
addDataExtractor(this, &QmlMultiLanguageAspect::origin, &Data::origin);
|
||||
|
||||
connect(this, &BoolAspect::changed, this, [this, target] {
|
||||
for (ProjectExplorer::RunControl *runControl :
|
||||
ProjectExplorer::ProjectExplorerPlugin::allRunControls()) {
|
||||
if (runControl->aspect<QmlMultiLanguageAspect>()->origin == this)
|
||||
runControl->initiateStop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QmlMultiLanguageAspect::~QmlMultiLanguageAspect()
|
||||
|
||||
@@ -50,10 +50,17 @@ public:
|
||||
static QmlMultiLanguageAspect *current(ProjectExplorer::Project *project);
|
||||
static QmlMultiLanguageAspect *current(ProjectExplorer::Target *target);
|
||||
|
||||
struct Data : BaseAspect::Data
|
||||
{
|
||||
const void *origin = nullptr;
|
||||
};
|
||||
|
||||
signals:
|
||||
void currentLocaleChanged(const QString &locale);
|
||||
|
||||
private:
|
||||
const void *origin() const { return this; }
|
||||
|
||||
ProjectExplorer::Target *m_target = nullptr;
|
||||
mutable Utils::FilePath m_databaseFilePath;
|
||||
QString m_currentLocale;
|
||||
|
||||
Reference in New Issue
Block a user