Possible KUniqueApplication and KCmdLineArgs issue

Christian Esken esken at kde.org
Wed Aug 10 01:17:25 BST 2005


Hello all,

I am encountering a strange behaviour with KCmdLineArgs and KMix (a KUniqueApplication).
I am quite aware that this is just a small issue, and could possibly simply be solved by enhancing the API docs.
Still, somebody knowledgable with these classes should look into it.

Lets go:
1) The current KMix has no command line options. This works fine.

2) In my working copy I added a "keepvisibility" option to KMix. But with this I receive:
kmix: kcmdlineargs.cpp:231: static void KCmdLineArgs::addCmdLineOptions(const KCmdLineOptions*, const char*, const char*, const char*): Assertion `parsed == false' failed.

3) I have not called "KUniqueApplication::addCmdLineOptions()" , and if I add this statement, everything is fine. So my personal problem is solved.

Butttttt! Why does the assertion fail?!? Is KUniqueApplication::addCmdLineOptions() possibly called implictely? In any case the assertion message is very misleading. And the API docs on KUniqueApplication are not really enforcing the usage of "KUniqueApplication::addCmdLineOptions()". There is just a "typically this is used like" clause.
OK, so what should be done? API-docs enhancement or kdelibs enhancement.

 Chris


--------------------------------------------------------------------------------------------------------------------------------------------
Appendix (for the curious):

Command line options
-----------------------------------
static KCmdLineOptions options[] =
{
   { "keepvisibility", I18N_NOOP("Inhibits the unhiding of the KMix main window, if KMix is already running."), 0 },
   KCmdLineLastOption
   // INSERT YOUR COMMANDLINE OPTIONS HERE
};


gdb run:
-----------------------------------
Breakpoint 2, kdemain (argc=1, argv=0xbffff114) at main.cpp:60
60         KCmdLineArgs::init( argc, argv, &aboutData );
(gdb) n
61         KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
(gdb)
64         KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
(gdb)
65         if (args->isSet("keepvisibility")) {
(gdb)
68         if (!KMixApp::start())
(gdb) s
kmix: kcmdlineargs.cpp:231: static void KCmdLineArgs::addCmdLineOptions(const KCmdLineOptions*, const char*, const char*, const char*): Assertion `parsed == false' failed.

Program received signal SIGABRT, Aborted.
0xffffe410 in ?? ()




More information about the kde-core-devel mailing list