summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2021-04-30 16:52:03 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-06-22 12:42:53 +0000
commit5b0889777a786698f801c2703f57b3648daeb40a (patch)
tree0023ebdf564f47138595526c648449590d62431f
parent7e874544e62ed46a1ef1c17f89b598a879becd70 (diff)
downloadqt-creator-5b0889777a786698f801c2703f57b3648daeb40a.tar.gz
Add a test for a crash in ModelManagerInterface
Task-number: QTCREATORBUG-25350 Change-Id: I4ea31e7936cc77dcd8f3fc494b5ecbd83858a766 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/libs/extensionsystem/pluginmanager.cpp6
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.cpp14
-rw-r--r--src/plugins/autotest/autotestplugin.cpp2
-rw-r--r--src/plugins/autotest/autotestunittests.cpp16
-rw-r--r--src/plugins/autotest/autotestunittests.h1
5 files changed, 36 insertions, 3 deletions
diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp
index 7e6693ea2d..524f4a04c0 100644
--- a/src/libs/extensionsystem/pluginmanager.cpp
+++ b/src/libs/extensionsystem/pluginmanager.cpp
@@ -1393,6 +1393,12 @@ void PluginManagerPrivate::shutdown()
shutdownEventLoop->exec();
}
deleteAll();
+#ifdef WITH_TESTS
+ if (PluginManager::isScenarioRunning("TestModelManagerInterface")) {
+ qDebug() << "Point 2: Expect the next call to Point 3 triggers a crash";
+ QThread::currentThread()->sleep(5);
+ }
+#endif
if (!allObjects.isEmpty()) {
qDebug() << "There are" << allObjects.size() << "objects left in the plugin manager pool.";
// Intentionally split debug info here, since in case the list contains
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index f500114016..688199b37a 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
@@ -40,6 +40,10 @@
#include <utils/runextensions.h>
#include <utils/stringutils.h>
+#ifdef WITH_TESTS
+#include <extensionsystem/pluginmanager.h>
+#endif
+
#include <QDir>
#include <QDirIterator>
#include <QFile>
@@ -969,6 +973,16 @@ void ModelManagerInterface::parseLoop(QSet<QString> &scannedPaths,
doc->setSource(contents);
doc->parse();
+#ifdef WITH_TESTS
+ if (ExtensionSystem::PluginManager::isScenarioRunning("TestModelManagerInterface")) {
+ ExtensionSystem::PluginManager::waitForScenarioFullyInitialized();
+ if (ExtensionSystem::PluginManager::finishScenario()) {
+ qDebug() << "Point 1: Shutdown triggered";
+ QThread::currentThread()->sleep(2);
+ qDebug() << "Point 3: If Point 2 was already reached, expect a crash now";
+ }
+ }
+#endif
// update snapshot. requires synchronization, but significantly reduces amount of file
// system queries for library imports because queries are cached in libraryInfo
const Snapshot snapshot = modelManager->snapshot();
diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp
index 43e54ec58c..277e346fc6 100644
--- a/src/plugins/autotest/autotestplugin.cpp
+++ b/src/plugins/autotest/autotestplugin.cpp
@@ -280,6 +280,8 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
#ifdef WITH_TESTS
ExtensionSystem::PluginManager::registerScenario("TestStringTable",
[this]() { return dd->m_loadProjectScenario(); });
+ ExtensionSystem::PluginManager::registerScenario("TestModelManagerInterface",
+ [this]() { return dd->m_loadProjectScenario(); });
#endif
return true;
}
diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp
index 6a6a9c1006..3ce4c69a28 100644
--- a/src/plugins/autotest/autotestunittests.cpp
+++ b/src/plugins/autotest/autotestunittests.cpp
@@ -308,13 +308,23 @@ void AutoTestUnitTests::testCodeParserBoostTest_data()
<< QString(m_tmpDir->path() + "/simple_boost/simple_boost.qbs") << QString(".qbs");
}
-void AutoTestUnitTests::testStringTable()
+static int executeScenario(const QString &scenario)
{
const PluginManager::ProcessData data = PluginManager::creatorProcessData();
- QStringList additionalArgs{ "-scenario", "TestStringTable" };
+ QStringList additionalArgs{ "-scenario", scenario };
if (!data.m_args.contains("-settingspath") && !data.m_settingsPath.isEmpty())
additionalArgs << "-settingspath" << data.m_settingsPath;
- QCOMPARE(QProcess::execute(data.m_executable, data.m_args + additionalArgs), 0);
+ return QProcess::execute(data.m_executable, data.m_args + additionalArgs);
+}
+
+void AutoTestUnitTests::testStringTable()
+{
+ QCOMPARE(executeScenario("TestStringTable"), 0);
+}
+
+void AutoTestUnitTests::testModelManagerInterface()
+{
+ QCOMPARE(executeScenario("TestModelManagerInterface"), 0);
}
} // namespace Internal
diff --git a/src/plugins/autotest/autotestunittests.h b/src/plugins/autotest/autotestunittests.h
index dcb4fe8657..7d38399645 100644
--- a/src/plugins/autotest/autotestunittests.h
+++ b/src/plugins/autotest/autotestunittests.h
@@ -56,6 +56,7 @@ private slots:
void testCodeParserBoostTest();
void testCodeParserBoostTest_data();
void testStringTable();
+ void testModelManagerInterface();
private:
TestTreeModel *m_model = nullptr;