ExtensionSystem: Add option to skip startup crash check

It can lead to problems, especially in automated environments, so
provide an option to skip it.

Task-number: QTCREATORBUG-24294
Change-Id: Ided0d12a87dc60fcaee6ad7e2747982cb0806a8f
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2020-08-12 14:11:28 +02:00
parent 1e09b01d0e
commit bd6161e2b2
4 changed files with 27 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ const char *OptionsParser::LOAD_OPTION = "-load";
const char *OptionsParser::TEST_OPTION = "-test"; const char *OptionsParser::TEST_OPTION = "-test";
const char *OptionsParser::NOTEST_OPTION = "-notest"; const char *OptionsParser::NOTEST_OPTION = "-notest";
const char *OptionsParser::PROFILE_OPTION = "-profile"; const char *OptionsParser::PROFILE_OPTION = "-profile";
const char *OptionsParser::NO_CRASHCHECK_OPTION = "-no-crashcheck";
OptionsParser::OptionsParser(const QStringList &args, OptionsParser::OptionsParser(const QStringList &args,
const QMap<QString, bool> &appOptions, const QMap<QString, bool> &appOptions,
@@ -79,6 +80,8 @@ bool OptionsParser::parse()
continue; continue;
if (checkForProfilingOption()) if (checkForProfilingOption())
continue; continue;
if (checkForNoCrashcheckOption())
continue;
#ifdef WITH_TESTS #ifdef WITH_TESTS
if (checkForTestOptions()) if (checkForTestOptions())
continue; continue;
@@ -243,6 +246,14 @@ bool OptionsParser::checkForProfilingOption()
return true; return true;
} }
bool OptionsParser::checkForNoCrashcheckOption()
{
if (m_currentArg != QLatin1String(NO_CRASHCHECK_OPTION))
return false;
m_pmPrivate->enableCrashCheck = false;
return true;
}
bool OptionsParser::checkForPluginOption() bool OptionsParser::checkForPluginOption()
{ {
bool requiresParameter; bool requiresParameter;

View File

@@ -49,6 +49,8 @@ public:
static const char *TEST_OPTION; static const char *TEST_OPTION;
static const char *NOTEST_OPTION; static const char *NOTEST_OPTION;
static const char *PROFILE_OPTION; static const char *PROFILE_OPTION;
static const char *NO_CRASHCHECK_OPTION;
private: private:
// return value indicates if the option was processed // return value indicates if the option was processed
// it doesn't indicate success (--> m_hasError) // it doesn't indicate success (--> m_hasError)
@@ -59,6 +61,7 @@ private:
bool checkForAppOption(); bool checkForAppOption();
bool checkForPluginOption(); bool checkForPluginOption();
bool checkForProfilingOption(); bool checkForProfilingOption();
bool checkForNoCrashcheckOption();
bool checkForUnknownOption(); bool checkForUnknownOption();
void forceDisableAllPluginsExceptTestedAndForceEnabled(); void forceDisableAllPluginsExceptTestedAndForceEnabled();

View File

@@ -64,6 +64,7 @@
#endif #endif
#include <functional> #include <functional>
#include <memory>
Q_LOGGING_CATEGORY(pluginLog, "qtc.extensionsystem", QtWarningMsg) Q_LOGGING_CATEGORY(pluginLog, "qtc.extensionsystem", QtWarningMsg)
@@ -729,6 +730,12 @@ void PluginManager::formatOptions(QTextStream &str, int optionIndentation, int d
formatOption(str, QLatin1String(OptionsParser::PROFILE_OPTION), formatOption(str, QLatin1String(OptionsParser::PROFILE_OPTION),
QString(), QLatin1String("Profile plugin loading"), QString(), QLatin1String("Profile plugin loading"),
optionIndentation, descriptionIndentation); optionIndentation, descriptionIndentation);
formatOption(str,
QLatin1String(OptionsParser::NO_CRASHCHECK_OPTION),
QString(),
QLatin1String("Disable startup check for previously crashed instance"),
optionIndentation,
descriptionIndentation);
#ifdef WITH_TESTS #ifdef WITH_TESTS
formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION) formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION)
+ QLatin1String(" <plugin>[,testfunction[:testdata]]..."), QString(), + QLatin1String(" <plugin>[,testfunction[:testdata]]..."), QString(),
@@ -1409,6 +1416,8 @@ private:
void PluginManagerPrivate::checkForProblematicPlugins() void PluginManagerPrivate::checkForProblematicPlugins()
{ {
if (!enableCrashCheck)
return;
const Utils::optional<QString> pluginName = LockFile::lockedPluginName(this); const Utils::optional<QString> pluginName = LockFile::lockedPluginName(this);
if (pluginName) { if (pluginName) {
PluginSpec *spec = pluginByName(*pluginName); PluginSpec *spec = pluginByName(*pluginName);
@@ -1464,7 +1473,9 @@ void PluginManagerPrivate::loadPlugin(PluginSpec *spec, PluginSpec::State destSt
if (!spec->isEffectivelyEnabled() && destState == PluginSpec::Loaded) if (!spec->isEffectivelyEnabled() && destState == PluginSpec::Loaded)
return; return;
LockFile f(this, spec); std::unique_ptr<LockFile> lockFile;
if (enableCrashCheck)
lockFile.reset(new LockFile(this, spec));
switch (destState) { switch (destState) {
case PluginSpec::Running: case PluginSpec::Running:

View File

@@ -138,6 +138,7 @@ public:
mutable QReadWriteLock m_lock; mutable QReadWriteLock m_lock;
bool m_isInitializationDone = false; bool m_isInitializationDone = false;
bool enableCrashCheck = true;
private: private:
PluginManager *q; PluginManager *q;