Results 1 to 11 of 11

Thread: Restore an application that is running while using QtSingleApplication

  1. #1

    Question Restore an application that is running while using QtSingleApplication

    While a QtSingleApplication is running, if there is an attempt to start another instance of the application, is there a way to restore the application that is already running?

  2. #2
    Join Date
    Apr 2007
    Posts
    46
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    Sorry for off-topic, but I badly need the QtSingleApplication code, can you send it over to
    <mail address deleted>
    Thank you in advance.
    Last edited by wysota; 24th June 2007 at 10:15. Reason: user request: mail address removed

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    Quote Originally Posted by ber_44 View Post
    Sorry for off-topic, but I badly need the QtSingleApplication code, can you send it over to
    If you need that code, you will have to buy a licence from the Trolls.

  4. #4
    Join Date
    Apr 2007
    Posts
    46
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    Quote Originally Posted by jacek View Post
    If you need that code, you will have to buy a licence from the Trolls.
    I don't mind having it unlicensed. Or do you know another solution that does not cost $$$?

  5. #5
    Join Date
    Aug 2006
    Posts
    44
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    Quote Originally Posted by ber_44 View Post
    I don't mind having it unlicensed. Or do you know another solution that does not cost $$$?
    I'm sure you would not mind obtaining it improperly, but Trolltech would not take it kindly if their paying customers violated their license agreements and started giving away their product. That's um... what's the word? Oh, yeah... Illegal.

    I'm pretty sure if you search the forums, solutions to the 'single instance' that don't use the QtSingleApplication class from the Qt Solutions product have been discussed.

  6. #6
    Join Date
    Apr 2007
    Posts
    46
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    Quote Originally Posted by Eldritch View Post
    I'm pretty sure if you search the forums, solutions to the 'single instance' that don't use the QtSingleApplication class from the Qt Solutions product have been discussed.
    There is one thread at http://www.qtcentre.org/forum/f-qt-p...r-not-160.html
    but it actually discusses a different problem than what its title suggests.
    What solutions did you find?

  7. #7
    Join Date
    Aug 2006
    Posts
    44
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    Here is one (it also mentions QtSingleApplication. ;-)

    Often, the best solutions are platform-specific. You can use named pipes, a TCP or UPD connection, a simple file (these are all portable). In MSWin, the standard trick is a named mutex (not available on other platforms). I haven't looked at the code for QtSingleApplication, but it suggests the use of some form of pipe or socket just from its method list.

    To the O.P.'s question. When the new instance checks for a previous one, the previous one will receive the text you send it. When it receives that message, it can activate its main window. It may not make the app jump to front (there's already a seperate thread about this), but it will restore its window if minimized, etc.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Restore an application that is running while using QtSingleApplication

    Quote Originally Posted by Eldritch View Post
    n MSWin, the standard trick is a named mutex (not available on other platforms).
    On u*ix you can use system semaphores or message queues for that. Based on the fact that MacOS is also a u*ix, it should be available there as well. On modern Linuxes, it would be wise to just use dbus

  9. #9
    Join Date
    Apr 2007
    Posts
    46
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    One thing that bothers me now is that when the user exits with Alt+F4 or through the Task Manager, then the mutex/textfile/etc. will never get deleted, so it will be impossible to restart the program.

  10. #10
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Restore an application that is running while using QtSingleApplication

    so... there is no gpl code available for doing this?

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Restore an application that is running while using QtSingleApplication

    Quote Originally Posted by ber_44 View Post
    One thing that bothers me now is that when the user exits with Alt+F4 or through the Task Manager, then the mutex/textfile/etc. will never get deleted, so it will be impossible to restart the program.
    You should be able to catch the signal using C function signal() and clean up the mutex before exiting the program.

Similar Threads

  1. Running the application
    By Afflicted.d2 in forum Installation and Deployment
    Replies: 9
    Last Post: 21st October 2006, 22:04
  2. Running application on Mac OS X
    By munna in forum General Discussion
    Replies: 1
    Last Post: 19th April 2006, 20:10
  3. Replies: 5
    Last Post: 16th January 2006, 05:15

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.