Bug 260349 - Failure to save current playlist on session shutdown
Summary: Failure to save current playlist on session shutdown
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 2.4-GIT
Platform: Compiled Sources Linux
: HI normal
Target Milestone: 2.4.0
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-17 09:51 UTC by Ben Cooksley
Modified: 2011-01-04 16:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 2.4
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Cooksley 2010-12-17 09:51:27 UTC
Version:           unspecified (using Devel) 
OS:                Linux

Amarok fails to save the current playlist successfully on logout, whilst successfully saving it when it is manually Quit. The unsaved playlist is completely lost.

Reproducible: Didn't try
Comment 1 Sergey Ivanov 2011-01-02 18:43:33 UTC
commit d1536e41e8faddac3a07329744abba7b22d2dd74
branch master
Author: Sergey Ivanov <123kash@gmail.com>
Date:   Sun Jan 2 20:42:55 2011 +0300

    Make amarok save current playlist in case of forced application termination (
    logout, Ctr+C in console, etc).
    BUG: 260349

diff --git a/src/main.cpp b/src/main.cpp
index 2e1e43c..a1f64d9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -23,12 +23,13 @@
 #include <KCmdLineArgs>
 #include <KDebug>
 
+#include <csignal>
+
 //#define AMAROK_USE_DRKONQI
 
 extern AMAROK_EXPORT class KAboutData aboutData; //defined in App.cpp
 extern AMAROK_EXPORT class OcsData ocsData;
 
-
 int main( int argc, char *argv[] )
 {
     //Authors
@@ -256,6 +257,12 @@ int main( int argc, char *argv[] )
         return 0;
     }
 
+    // Rewrite default SIGINT and SIGTERM handlers
+    // to make amarok save current playlists during forced
+    // application termination (logout, Ctr+C in console etc.)
+    signal( SIGINT, &QCoreApplication::exit );
+    signal( SIGTERM, &QCoreApplication::exit );
+
     App app;
     app.setUniqueInstance( startFlag == KUniqueApplication::NonUniqueInstance );
     return app.exec();