forked from qt-creator/qt-creator
QtSupport: Do not keep hold on a list of qtVersion
Can get invalidated, and lead to a crash. Task-number: QTCREATORBUG-17644 Change-Id: Idc704ae8833ff12abd046a667f242b672d98f9b2 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -92,9 +92,7 @@ void ExampleSetModel::update()
|
|||||||
extraManifestDirs.insert(set.manifestPath);
|
extraManifestDirs.insert(set.manifestPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<BaseQtVersion *> qtVersions = examplesModel->qtVersions();
|
foreach (BaseQtVersion *version, QtVersionManager::versions()) {
|
||||||
|
|
||||||
foreach (BaseQtVersion *version, qtVersions) {
|
|
||||||
// sanitize away qt versions that have already been added through extra sets
|
// sanitize away qt versions that have already been added through extra sets
|
||||||
if (extraManifestDirs.contains(version->documentationPath())) {
|
if (extraManifestDirs.contains(version->documentationPath())) {
|
||||||
if (debugExamples()) {
|
if (debugExamples()) {
|
||||||
@@ -488,11 +486,6 @@ void ExamplesListModel::updateQtVersions()
|
|||||||
if (defaultVersion && versions.contains(defaultVersion))
|
if (defaultVersion && versions.contains(defaultVersion))
|
||||||
versions.move(versions.indexOf(defaultVersion), 0);
|
versions.move(versions.indexOf(defaultVersion), 0);
|
||||||
|
|
||||||
if (m_qtVersions == versions && m_selectedExampleSetIndex >= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_qtVersions = versions;
|
|
||||||
|
|
||||||
m_exampleSetModel->update();
|
m_exampleSetModel->update();
|
||||||
|
|
||||||
int currentIndex = m_selectedExampleSetIndex;
|
int currentIndex = m_selectedExampleSetIndex;
|
||||||
@@ -510,9 +503,7 @@ void ExamplesListModel::updateQtVersions()
|
|||||||
// try to select the previously selected Qt version, or
|
// try to select the previously selected Qt version, or
|
||||||
// select examples corresponding to 'highest' Qt version
|
// select examples corresponding to 'highest' Qt version
|
||||||
int currentQtId = m_exampleSetModel->getQtId(currentIndex);
|
int currentQtId = m_exampleSetModel->getQtId(currentIndex);
|
||||||
BaseQtVersion *newQtVersion = Utils::findOrDefault(m_qtVersions,
|
BaseQtVersion *newQtVersion = QtVersionManager::version(currentQtId);
|
||||||
Utils::equal(&BaseQtVersion::uniqueId, currentQtId));
|
|
||||||
|
|
||||||
if (!newQtVersion)
|
if (!newQtVersion)
|
||||||
newQtVersion = findHighestQtVersion();
|
newQtVersion = findHighestQtVersion();
|
||||||
currentIndex = m_exampleSetModel->indexForQtVersion(newQtVersion);
|
currentIndex = m_exampleSetModel->indexForQtVersion(newQtVersion);
|
||||||
@@ -522,11 +513,10 @@ void ExamplesListModel::updateQtVersions()
|
|||||||
|
|
||||||
BaseQtVersion *ExamplesListModel::findHighestQtVersion() const
|
BaseQtVersion *ExamplesListModel::findHighestQtVersion() const
|
||||||
{
|
{
|
||||||
QList<BaseQtVersion *> versions = qtVersions();
|
BaseQtVersion *newVersion = nullptr;
|
||||||
|
|
||||||
BaseQtVersion *newVersion = 0;
|
const QList<BaseQtVersion *> versions = QtVersionManager::versions();
|
||||||
|
for (BaseQtVersion *version : versions) {
|
||||||
foreach (BaseQtVersion *version, versions) {
|
|
||||||
if (!newVersion) {
|
if (!newVersion) {
|
||||||
newVersion = version;
|
newVersion = version;
|
||||||
} else {
|
} else {
|
||||||
@@ -542,9 +532,6 @@ BaseQtVersion *ExamplesListModel::findHighestQtVersion() const
|
|||||||
if (!newVersion && !versions.isEmpty())
|
if (!newVersion && !versions.isEmpty())
|
||||||
newVersion = versions.first();
|
newVersion = versions.first();
|
||||||
|
|
||||||
if (!newVersion)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return newVersion;
|
return newVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,7 +556,7 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr
|
|||||||
demosPath = exampleSet.examplesPath;
|
demosPath = exampleSet.examplesPath;
|
||||||
} else if (currentType == ExampleSetModel::QtExampleSet) {
|
} else if (currentType == ExampleSetModel::QtExampleSet) {
|
||||||
int qtId = m_exampleSetModel->getQtId(m_selectedExampleSetIndex);
|
int qtId = m_exampleSetModel->getQtId(m_selectedExampleSetIndex);
|
||||||
foreach (BaseQtVersion *version, qtVersions()) {
|
foreach (BaseQtVersion *version, QtVersionManager::versions()) {
|
||||||
if (version->uniqueId() == qtId) {
|
if (version->uniqueId() == qtId) {
|
||||||
manifestScanPath = version->documentationPath();
|
manifestScanPath = version->documentationPath();
|
||||||
examplesPath = version->examplesPath();
|
examplesPath = version->examplesPath();
|
||||||
@@ -651,7 +638,7 @@ void ExamplesListModel::selectExampleSet(int index)
|
|||||||
|
|
||||||
QStringList ExamplesListModel::exampleSets() const
|
QStringList ExamplesListModel::exampleSets() const
|
||||||
{
|
{
|
||||||
return Utils::transform(m_qtVersions, &BaseQtVersion::displayName);
|
return Utils::transform(QtVersionManager::versions(), &BaseQtVersion::displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, bool showTutorialsOnly, QObject *parent) :
|
ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, bool showTutorialsOnly, QObject *parent) :
|
||||||
|
@@ -117,7 +117,6 @@ public:
|
|||||||
int selectedExampleSet() const;
|
int selectedExampleSet() const;
|
||||||
void selectExampleSet(int index);
|
void selectExampleSet(int index);
|
||||||
|
|
||||||
QList<BaseQtVersion*> qtVersions() const { return m_qtVersions; }
|
|
||||||
QList<ExtraExampleSet> extraExampleSets() const { return m_extraExampleSets; }
|
QList<ExtraExampleSet> extraExampleSets() const { return m_extraExampleSets; }
|
||||||
QStringList exampleSets() const;
|
QStringList exampleSets() const;
|
||||||
|
|
||||||
@@ -139,7 +138,6 @@ private:
|
|||||||
QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath);
|
QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath);
|
||||||
|
|
||||||
ExampleSetModel* m_exampleSetModel;
|
ExampleSetModel* m_exampleSetModel;
|
||||||
QList<BaseQtVersion*> m_qtVersions;
|
|
||||||
QList<ExtraExampleSet> m_extraExampleSets;
|
QList<ExtraExampleSet> m_extraExampleSets;
|
||||||
QList<ExampleItem> m_exampleItems;
|
QList<ExampleItem> m_exampleItems;
|
||||||
int m_selectedExampleSetIndex = -1;
|
int m_selectedExampleSetIndex = -1;
|
||||||
|
Reference in New Issue
Block a user