Possible KUniqueApplication and KCmdLineArgs issue
Waldo Bastian
bastian at kde.org
Wed Aug 10 12:52:11 BST 2005
On Wednesday 10 August 2005 02:17, Christian Esken wrote:
> 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?!?
You must add all command line options before you use them with
KCmdLineArgs::parsedArgs(). Normally KUniqueApplication::addCmdLineOptions()
is called in KUniqueApplication::start() or the KUniqueApplication
constructor but if you want to use command line options before that you must
add the KUniqueApplication command line options yourself before you use them.
Feel free to update the API-docs to make this more clear.
Cheers,
Waldo
> 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 ?? ()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050810/e0ac743c/attachment.sig>
More information about the kde-core-devel
mailing list