--- komics/src/main.cpp.orig 2004-10-10 13:54:07.000000000 -0300 +++ komics/src/main.cpp 2006-07-19 14:41:56.000000000 -0300 @@ -23,19 +23,22 @@ I18N_NOOP(__comment), KAboutData::License_GPL_V2, "(C) 2003 Natella Roberto", 0, "roberto.natella@virgilio.it" ); - about.addAuthor("Roberto Natella", 0, - "roberto.natella@virgilio.it", "http://www.orson.it/" ); + about.addAuthor("Roberto Natella", 0, + "roberto.natella@virgilio.it", "http://www.orson.it/" ); - KCmdLineArgs::init( argc, argv, &about); + KCmdLineArgs::init( argc, argv, &about); - KApplication::disableAutoDcopRegistration(); + KApplication::disableAutoDcopRegistration(); + + if (!KUniqueApplication::start()) { + fprintf(stderr, i18n( QString("Unable to start the application. Another instance was already started."))); + exit(0); + } KUniqueApplication app; - if( !Komics::lock() ) - return -1; Komics * komics = new Komics(0,new KConfig("libkomicsrc")); - + if( komics == NULL ) return -1; @@ -46,8 +49,6 @@ int ret = app.exec(); delete komics; - Komics::unlock(); - return ret; } --- komics/src/komics.cpp.orig 2004-10-10 17:14:19.000000000 -0300 +++ komics/src/komics.cpp 2006-07-19 14:41:52.000000000 -0300 @@ -1315,40 +1315,9 @@ return url; } -bool Komics::lock() -{ - QString lock = locateLocal("data", "komics/lock"); - KSimpleConfig config(lock); - - int pid = config.readNumEntry("pid", -1); - - if ( pid > -1 ) - { - KMessageBox::sorry(0, i18n( QString("Unable to start the application. Please check if another instance was already started. If not, delete the lockfile $HOME/.kde/share/apps/komics/lock .") )); - return false; - } - - config.writeEntry("pid", getpid()); - config.sync(); - - return true; -} - -bool Komics::unlock() -{ - QString lock = locateLocal("data", "komics/lock"); - KSimpleConfig config(lock); - - config.writeEntry("pid", -1); - config.sync(); - - return true; -} - void Komics::shutDown() { writeHistory(); - unlock(); } KomicsApplet::KomicsApplet(const QString& configFile, Type type, int actions, QWidget *parent, const char *name) @@ -1394,17 +1363,9 @@ { KPanelApplet* init( QWidget *parent, const QString configFile ) { - - if(!Komics::lock()) - { - return 0; - } - else - { - KGlobal::locale()->insertCatalogue("Komics"); - return new KomicsApplet(configFile, KPanelApplet::Normal, - KPanelApplet::About | KPanelApplet::Preferences, - parent, "Komics"); - } + KGlobal::locale()->insertCatalogue("Komics"); + return new KomicsApplet(configFile, KPanelApplet::Normal, + KPanelApplet::About | KPanelApplet::Preferences, + parent, "Komics"); } }