Commit d8c5a241 authored by David Jarvie's avatar David Jarvie

Bug 371628: Fix crash when a second instance of KAlarm is started

KDBusService doesn't supply any command line arguments in its
activateRequested() signal unless there is at least one command
line option (in addition to the program name) in the command

Forward port of Applications/16.08 commit
parent b6496232
KAlarm Change Log
=== Version 2.11.10 (KDE Applications 16.08.3) --- 21 October 2016 ===
=== Version 2.11.10 (KDE Applications 16.08.3) --- 30 October 2016 ===
+ Fix default calendar files not being created on first run [KDE Bug 362962]
+ Fix crash when a second instance of KAlarm is started [KDE Bug 371628]
=== Version 2.11.9 (KDE Applications 16.08.1) --- 18 August 2016 ===
* Prevent KAlarm autostarting on non-KDE desktops if it has never been run [KDE Bug 366562]
......@@ -122,7 +122,7 @@ KAlarmApp::KAlarmApp(int& argc, char** argv)
// Make this a unique application.
KDBusService* s = new KDBusService(KDBusService::Unique);
KDBusService* s = new KDBusService(KDBusService::Unique, this);
connect(this, &KAlarmApp::aboutToQuit, s, &KDBusService::deleteLater);
connect(s, &KDBusService::activateRequested, this, &KAlarmApp::activate);
......@@ -335,11 +335,19 @@ void KAlarmApp::activate(const QStringList& args, const QString& workingDirector
// The D-Bus call to activate a subsequent instance of KAlarm may not supply
// any arguments, but we need one.
if (!args.isEmpty() && mActivateArg0.isEmpty())
mActivateArg0 = args[0];
QStringList fixedArgs(args);
if (args.isEmpty() && !mActivateArg0.isEmpty())
fixedArgs << mActivateArg0;
// Parse and interpret command line arguments.
QCommandLineParser parser;
const QStringList newArgs = CommandOptions::setOptions(&parser, args);
const QStringList newArgs = CommandOptions::setOptions(&parser, fixedArgs);
......@@ -196,6 +196,7 @@ class KAlarmApp : public QApplication
bool mQuitting; // a forced quit is in progress
bool mReadOnly; // only read-only access to calendars is needed
bool mLoginAlarmsDone; // alarms repeated at login have been processed
QString mActivateArg0; // activate()'s first arg the first time it was called
DBusHandler* mDBusHandler; // the parent of the main DCOP receiver object
TrayWindow* mTrayWindow; // active system tray icon
QTimer* mAlarmTimer; // activates KAlarm when next alarm is due
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment