Results 1 to 4 of 4

Thread: Small class for restricting an application to one instance available

  1. #1
    Join Date
    Jan 2007
    Posts
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 for the implementation.

    Feel free to send comments, improvements and/or bug reports

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Small class for restricting an application to one instance available

    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.

  3. #3
    Join Date
    Jan 2007
    Posts
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Small class for restricting an application to one instance available

    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 )

  4. #4
    Join Date
    Jan 2007
    Posts
    13
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Small class for restricting an application to one instance available

    There is a new implemenation using QLocalServer/QLocalSocket available on the wiki.

    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

Similar Threads

  1. Replies: 2
    Last Post: 16th March 2007, 09:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.