aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-08-17 17:41:42 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-08-19 13:55:29 +0000
commit790757a8e8092e490bb6455a7ce290b35138fe50 (patch)
tree64dc947f87148b4bc2668eab1aa7f8402d5fe574
parentabffbe380623b2cf45571eab4ca3ae7558a7d151 (diff)
AutoTest: Fix persisting of check states
Persistent settings cannot handle QVariantHash and when reading the check state the meta type system seems to have the need to have used the check state already before, otherwise it will fail to convert until it uses it. This happened e.g. when re-opening a project that had former check states stored inside the project settings directly from the Welcome page after starting QC. Amends df49d6e40df47. Change-Id: Id2b85373c151efb5890fe5fb7392bdbc11adda50 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/autotest/autotestplugin.cpp2
-rw-r--r--src/plugins/autotest/itemdatacache.h6
-rw-r--r--src/plugins/autotest/testprojectsettings.cpp5
3 files changed, 7 insertions, 6 deletions
diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp
index 9e01a295ce..bf0b3e7019 100644
--- a/src/plugins/autotest/autotestplugin.cpp
+++ b/src/plugins/autotest/autotestplugin.cpp
@@ -118,6 +118,8 @@ AutotestPlugin::AutotestPlugin()
qRegisterMetaType<TestResult>();
qRegisterMetaType<TestTreeItem *>();
qRegisterMetaType<TestCodeLocationAndType>();
+ // warm up meta type system to be able to read Qt::CheckState with persistent settings
+ qRegisterMetaType<Qt::CheckState>();
}
AutotestPlugin::~AutotestPlugin()
diff --git a/src/plugins/autotest/itemdatacache.h b/src/plugins/autotest/itemdatacache.h
index ae5569075b..6db2138842 100644
--- a/src/plugins/autotest/itemdatacache.h
+++ b/src/plugins/autotest/itemdatacache.h
@@ -58,15 +58,15 @@ public:
void clear() { m_cache.clear(); }
bool isEmpty() const { return m_cache.isEmpty(); }
- QVariantHash toSettings() const
+ QVariantMap toSettings() const
{
- QVariantHash result;
+ QVariantMap result;
for (auto it = m_cache.cbegin(), end = m_cache.cend(); it != end; ++it)
result.insert(it.key(), QVariant::fromValue(it.value().value));
return result;
}
- void fromSettings(const QVariantHash &stored)
+ void fromSettings(const QVariantMap &stored)
{
m_cache.clear();
for (auto it = stored.cbegin(), end = stored.cend(); it != end; ++it)
diff --git a/src/plugins/autotest/testprojectsettings.cpp b/src/plugins/autotest/testprojectsettings.cpp
index cfb3b60e31..61a2c99b4d 100644
--- a/src/plugins/autotest/testprojectsettings.cpp
+++ b/src/plugins/autotest/testprojectsettings.cpp
@@ -94,7 +94,7 @@ void TestProjectSettings::load()
const QVariant runAfterBuild = m_project->namedSettings(SK_RUN_AFTER_BUILD);
m_runAfterBuild = runAfterBuild.isValid() ? RunAfterBuildMode(runAfterBuild.toInt())
: RunAfterBuildMode::None;
- m_checkStateCache.fromSettings(m_project->namedSettings(SK_CHECK_STATES).toHash());
+ m_checkStateCache.fromSettings(m_project->namedSettings(SK_CHECK_STATES).toMap());
}
void TestProjectSettings::save()
@@ -106,8 +106,7 @@ void TestProjectSettings::save()
activeFrameworks.insert(it.key()->id().toString(), it.value());
m_project->setNamedSettings(SK_ACTIVE_FRAMEWORKS, activeFrameworks);
m_project->setNamedSettings(SK_RUN_AFTER_BUILD, int(m_runAfterBuild));
- if (!m_checkStateCache.isEmpty())
- m_project->setNamedSettings(SK_CHECK_STATES, m_checkStateCache.toSettings());
+ m_project->setNamedSettings(SK_CHECK_STATES, m_checkStateCache.toSettings());
}
} // namespace Internal