This forum has been archived. All content is frozen. Please use KDE Discuss instead.

KUniqueApplication warning when starting app the second time

Tags: None
(comma "," separated)
terraV
Registered Member
Posts
2
Karma
0
Hi,
I am trying to warn the user when he tries to start a unique application under Windows a second time. I use the following code:
if (!KUniqueApplication::start()) {
fprintf(stderr, "App is already running!");
exit(0);
}
// create the app
KUniqueApplication app;
The problem is that start() exits with code 255 because the dbusService can not be registered. I can register the dbus when no other instance of my application is running. So obviously the first instance causes the ::exit(255) which gives me no chance to warn the user.
Any idea how to solve this issue?

Thanks!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I think kdelibs already provides an error message. In any case, there isn't much you can do in this case. What you could do is implement the newInstance() part of KUniqueApplication in your application and use it to send your main window to the top.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
terraV
Registered Member
Posts
2
Karma
0
Thanks! Will check this...


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, mickae, Sogou [Bot]