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);
|
||||
}
|
||||
|
||||
QList<BaseQtVersion *> qtVersions = examplesModel->qtVersions();
|
||||
|
||||
foreach (BaseQtVersion *version, qtVersions) {
|
||||
foreach (BaseQtVersion *version, QtVersionManager::versions()) {
|
||||
// sanitize away qt versions that have already been added through extra sets
|
||||
if (extraManifestDirs.contains(version->documentationPath())) {
|
||||
if (debugExamples()) {
|
||||
@@ -488,11 +486,6 @@ void ExamplesListModel::updateQtVersions()
|
||||
if (defaultVersion && versions.contains(defaultVersion))
|
||||
versions.move(versions.indexOf(defaultVersion), 0);
|
||||
|
||||
if (m_qtVersions == versions && m_selectedExampleSetIndex >= 0)
|
||||
return;
|
||||
|
||||
m_qtVersions = versions;
|
||||
|
||||
m_exampleSetModel->update();
|
||||
|
||||
int currentIndex = m_selectedExampleSetIndex;
|
||||
@@ -510,9 +503,7 @@ void ExamplesListModel::updateQtVersions()
|
||||
// try to select the previously selected Qt version, or
|
||||
// select examples corresponding to 'highest' Qt version
|
||||
int currentQtId = m_exampleSetModel->getQtId(currentIndex);
|
||||
BaseQtVersion *newQtVersion = Utils::findOrDefault(m_qtVersions,
|
||||
Utils::equal(&BaseQtVersion::uniqueId, currentQtId));
|
||||
|
||||
BaseQtVersion *newQtVersion = QtVersionManager::version(currentQtId);
|
||||
if (!newQtVersion)
|
||||
newQtVersion = findHighestQtVersion();
|
||||
currentIndex = m_exampleSetModel->indexForQtVersion(newQtVersion);
|
||||
@@ -522,11 +513,10 @@ void ExamplesListModel::updateQtVersions()
|
||||
|
||||
BaseQtVersion *ExamplesListModel::findHighestQtVersion() const
|
||||
{
|
||||
QList<BaseQtVersion *> versions = qtVersions();
|
||||
BaseQtVersion *newVersion = nullptr;
|
||||
|
||||
BaseQtVersion *newVersion = 0;
|
||||
|
||||
foreach (BaseQtVersion *version, versions) {
|
||||
const QList<BaseQtVersion *> versions = QtVersionManager::versions();
|
||||
for (BaseQtVersion *version : versions) {
|
||||
if (!newVersion) {
|
||||
newVersion = version;
|
||||
} else {
|
||||
@@ -542,9 +532,6 @@ BaseQtVersion *ExamplesListModel::findHighestQtVersion() const
|
||||
if (!newVersion && !versions.isEmpty())
|
||||
newVersion = versions.first();
|
||||
|
||||
if (!newVersion)
|
||||
return 0;
|
||||
|
||||
return newVersion;
|
||||
}
|
||||
|
||||
@@ -569,7 +556,7 @@ QStringList ExamplesListModel::exampleSources(QString *examplesInstallPath, QStr
|
||||
demosPath = exampleSet.examplesPath;
|
||||
} else if (currentType == ExampleSetModel::QtExampleSet) {
|
||||
int qtId = m_exampleSetModel->getQtId(m_selectedExampleSetIndex);
|
||||
foreach (BaseQtVersion *version, qtVersions()) {
|
||||
foreach (BaseQtVersion *version, QtVersionManager::versions()) {
|
||||
if (version->uniqueId() == qtId) {
|
||||
manifestScanPath = version->documentationPath();
|
||||
examplesPath = version->examplesPath();
|
||||
@@ -651,7 +638,7 @@ void ExamplesListModel::selectExampleSet(int index)
|
||||
|
||||
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) :
|
||||
|
@@ -117,7 +117,6 @@ public:
|
||||
int selectedExampleSet() const;
|
||||
void selectExampleSet(int index);
|
||||
|
||||
QList<BaseQtVersion*> qtVersions() const { return m_qtVersions; }
|
||||
QList<ExtraExampleSet> extraExampleSets() const { return m_extraExampleSets; }
|
||||
QStringList exampleSets() const;
|
||||
|
||||
@@ -139,7 +138,6 @@ private:
|
||||
QStringList exampleSources(QString *examplesInstallPath, QString *demosInstallPath);
|
||||
|
||||
ExampleSetModel* m_exampleSetModel;
|
||||
QList<BaseQtVersion*> m_qtVersions;
|
||||
QList<ExtraExampleSet> m_extraExampleSets;
|
||||
QList<ExampleItem> m_exampleItems;
|
||||
int m_selectedExampleSetIndex = -1;
|
||||
|
Reference in New Issue
Block a user