Priority: Not Evaluated
Affects Version/s: Some Release
Fix Version/s: None
Component/s: Single Application
Environment:2.6.35-19-generic #28-Ubuntu SMP Sun Aug 29 06:34:38 UTC 2010 x86_64 GNU/Linux
I had code that looked like this in my main:
int main(int argc, char* argv)
QtSingleApplication app("my_unique_app", argc, argv);
QStringList cmdLineArgs = app.arguments();
qDebug() << "Shutdown selected";
qDebug() << "Shutdown No other instance found.";
Unfortunately, this doesn't work, because the second instance I start get false when calling app.isRunning(). I figured out why, it seems that calling "isRunning()" has the side effect of actually locking the QtLockedFile, and since my first instance didn't have the "isRunning()" check because the command line args didn't containt "shutdown", then the file is not locked.
If I had followed precisely the example I wouldn't have encountered the problem... and there is no mention in the documentation.
So either call QtLocalPeer::isClient() from it's constructor (to ensure lock) or explicitely mention that isRunning() should always be called, i.e. that it has the side-effect of actually declaring the first instance.