View Full Version : Small class for restricting an application to one instance available
I've coded a small class for restricting an application to one instance and sending messages to it. It is based on Qt 4.4 and uses QSharedMemory and QTimer. See SingleApplication (http://wiki.qtcentre.org/index.php?title=SingleApplication) for the implementation.
Feel free to send comments, improvements and/or bug reports :)
Great idea and clean implementation,
it was about time that somebody made the commercial QtSingleApplication obsolete. I'm just not fond of the single application polling the memory once a second to find out if somebody wrote to the memory. Have you seen the upcoming QLocalServer/QLocalSocket. I think they would be perfect for the inter process communication.
If used together with QSystemSemaphore(unfortunately Qt 4.5) you wouldn't need the shared memory at all.
Hello spud,
thanks a lot for your suggestion. Yes, the implementation using a timer is not quite clean although I think the time lost by it is manageable (at least the task manager of windows shows 0% performance on my machine). However, your idea using QLocalServer/QLocalSocket seems to be more straightforward. I'll take a look at your hint tomorrow and see if I can put something together (QSystemSemaphore is part of Qt 4.4 :) )
There is a new implemenation using QLocalServer/QLocalSocket available on the wiki (http://wiki.qtcentre.org/index.php?title=SingleApplication).
It seems to me that using QSystemSemaphore is not possible with Qt 4.4 since there is no possibility to monitor the number of running instances.
Regards, flare
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.