Add --no-respawn (-n) option to plasma-shell

Disables automatic restarting of plasma-shell, useful for debugging
purposes.

BUG:332515
This commit is contained in:
Sebastian Kügler 2014-03-25 02:25:09 +01:00
parent 900e0108e1
commit 637bf0ea19
3 changed files with 10 additions and 2 deletions

View File

@ -57,6 +57,10 @@ int main(int argc, char** argv)
QStringLiteral("windowed"),
QStringLiteral("Force a windowed view for testing purposes"));
QCommandLineOption respawn(QStringList() << QStringLiteral("n") <<
QStringLiteral("no-respawn"),
QStringLiteral("Do not restart plasma-shell automatically after a crash"));
QCommandLineOption crash(QStringList() << QStringLiteral("c") << QStringLiteral("crashes"),
QStringLiteral("Recent number of crashes"),
QStringLiteral("n"));
@ -68,6 +72,7 @@ int main(int argc, char** argv)
parser.addHelpOption();
parser.addOption(dbg);
parser.addOption(win);
parser.addOption(respawn);
parser.addOption(crash);
parser.addOption(shutup);
@ -80,6 +85,7 @@ int main(int argc, char** argv)
ShellManager::setCrashCount(parser.value(crash).toInt());
ShellManager::s_forceWindowed = parser.isSet(win);
ShellManager::s_noRespawn = parser.isSet(respawn);
ShellManager::instance();
return app.exec();

View File

@ -41,6 +41,7 @@ static const QString s_shellsDir = QString(QStandardPaths::locate(QStandardPaths
static const QString s_shellLoaderPath = QString("/contents/loader.qml");
bool ShellManager::s_forceWindowed = false;
bool ShellManager::s_noRespawn = false;
int ShellManager::crashes = 0;
@ -242,11 +243,11 @@ void ShellManager::crashHandler(int signal)
sprintf(cmd, "%s --crashes %d &",
QFile::encodeName(QCoreApplication::applicationFilePath()).constData(), crashes);
if (crashes < 3) {
if (crashes < 3 && !s_noRespawn) {
sleep(1);
system(cmd);
} else {
fprintf(stderr, "Too many crashes in short order, not restarting automatically.\n");
fprintf(stderr, "Too many crashes in short order or respawning disabled, not restarting automatically.\n");
}
}

View File

@ -41,6 +41,7 @@ public:
void loadHandlers();
static bool s_forceWindowed;
static bool s_noRespawn;
static void setCrashCount(int count);