From kde-commits Fri Oct 31 23:38:34 2008 From: Volker Krause Date: Fri, 31 Oct 2008 23:38:34 +0000 To: kde-commits Subject: KDE/kdepim/akonadi/migration/kres Message-Id: <1225496314.553074.17778.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=122549632309681 SVN commit 878349 by vkrause: make sure we don't run more than one instance per type in parallel M +18 -3 main.cpp --- trunk/KDE/kdepim/akonadi/migration/kres/main.cpp #878348:878349 @@ -28,6 +28,8 @@ #include #include +#include + void connectMigrator( KResMigratorBase *m, InfoDialog *dlg ) { if ( !dlg || !m ) @@ -64,13 +66,23 @@ KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + QStringList typesToMigrate; + foreach ( const QString &type, args->getOption( "type" ).split( ',' ) ) { + if ( !QDBusConnection::sessionBus().registerService( "org.kde.Akonadi.KResMigrator." + type ) ) + kWarning() << "Migrator instance already running for type " << type; + else + typesToMigrate << type; + } + if ( typesToMigrate.isEmpty() ) + return 1; + KApplication app; app.setQuitOnLastWindowClosed( false ); KGlobal::setAllowQuit( true ); if ( !Akonadi::Control::start( 0 ) ) - return 1; + return 2; InfoDialog *infoDialog = 0; if ( args->isSet( "interactive" ) || args->isSet( "interactive-on-change" ) ) { @@ -78,7 +90,7 @@ infoDialog->show(); } - foreach ( const QString &type, args->getOption( "type" ).split( ',' ) ) { + foreach ( const QString &type, typesToMigrate ) { KResMigratorBase *m = 0; if ( type == "contact" ) m = new KABCMigrator(); @@ -92,5 +104,8 @@ connectMigrator( m, infoDialog ); } - return app.exec(); + const int result = app.exec(); + if ( infoDialog && infoDialog->hasError() ) + return 3; + return result; }