![]() Registered Member ![]()
|
Hi!
I'm trying to migrate my KDE app to KDE4. The KApplication instance in the app is registering at DBus with a name generated from the web page of the app and the PID. When running without debugger it works fine, however, when trying to execute under gdb I got the following message when stepping over the KApplication constructor and the process exits: <app>(20533): Couldn't register name ' "<app>-20533" ' with DBUS - another process owns it already! I listed the registered service names on the system and session buses but no registration was present with that name. Checking the KDE sources, the registration is done and this error message comes from KApplicationPrivate::init, which is called by the KApplication constructors. Any idea why this happens? Thanks in advance! |
![]() Registered Member ![]()
|
OK, let me answer my own question. I think this is a bug in KApplication anyway.
In fact, KApplication is not telling the truth ![]() Noone has registered with the given name so far, but the QDBusConnectionInterface::registerService() call which fails during initialization will only tell you that the service was not registered but not giving any reason. KApplication in this case wrongly assumes that the fail reason is that the name is already in use, in fact the name was an invalid service name. Unfortunatelly I cut out the name in my post, so no one could point out this by just looking ![]() KApplication sets up the service name as
so I suppose, under gdb the q->applicationName() returns the full path. Why is to be examined, but I'd suggest to add some check here and use only the end of this string, after the last slash. |
![]() Registered Member ![]()
|
Answer to why is as easy as I passed argv[0] to KAboutData as the application name, which is also incorrect I think. Changing this to a fixed string solved my problem.
Conclusion: Application name set in KAboutData and passed to KCmdLineArgs::init will be used directly as part of KApplication's DBus service name, so have to be set with care. |
![]() Registered Member ![]()
|
One final comment
![]() According to the --help-qt message of any KDE app, the --name <name> argument should set the application name. This means, by writing e.g.
you can screw up the starting of any KDE application. Fortunatelly (?) the --name does not work (at least on my system), or sets some different app name, I could not find any difference in a short time checking, on a few KDE programs. Does it work for anybody? (I'm using KDE 4.2.2) |
![]() KDE Developer ![]()
|
I know this is an old post, but I just want to point out that you get this error if you initialize KAboutData's appName parameter with some name which includes a space.
Eg - "Sample App" won't work. "SampleApp" will. |
![]() KDE Developer ![]()
|
Interesting observations. Maybe this could be checked somewhere, e.g. in KAboutData or before the value is passed to QtDBus.
I am pretty sure a patch doing such a check would be accepted and applied. Chance to get some code into kdelibs ![]() Cheers, _
anda_skoa, proud to be a member of KDE forums since 2008-Oct.
|
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]