[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KCmdLineArgs4 Question
From: Richard =?iso-8859-1?q?L=E4rk=E4ng?= <nouseforaname () home ! se>
Date: 2005-12-31 11:31:44
Message-ID: 200512311231.46825.nouseforaname () home ! se
[Download RAW message or body]
Hi!
On Wednesday 28 December 2005 21:52, Allen Winter wrote:
> Hi Core Devs,
>
> [I asked Waldo about this and he suggested I ask here instead]
>
> I'm using the new KCmdLineArgs from kdelibs4_snapshot and running into a
> problem.
>
> Recall that konsolekalendar should not support any Qt or KDE options since
> it is a CLI program. IOW: I don't want 'konsolekalendar --help' to show
> any Qt or KDE specific command line args.
>
> When I have
> KCmdLineArgs::init( argc, argv, &aboutData,
> KCmdLineArgs::CmdLineArgNone); in konsolekalendar's main.cpp the result is
>
> % ./konsolekalendar --help-all
> ASSERT: "args" in file
> /misc/shared/kde/branches/work/kdelibs4_snapshot/kdecore/kcmdlineargs.cpp,
> line 748 Aborted
>
> What am I doing wrong?
> Regards,
> Allen
I ran in to the same problem when checking if audiocd:/ worked. The problem
seems to be that in KDE 3 the qt args are added anyway (in
KApplication::addCmdLineOptions) so the assert wasn't triggered. But in
kdelibs from trunk the qt args are only added if requested (KCmdLineArgs::
addStdCmdLineOptions)
So I made a patch so it only checks for the qt args in qt_argc and qt_argv if
they are requested, and otherwise returns just the application name as argv.
Could anyone have a look at the attached patch?
/Richard Lärkäng
["kcmdlineargs.patch" (text/x-diff)]
Index: kcmdlineargs.cpp
===================================================================
--- kcmdlineargs.cpp (revision 492369)
+++ kcmdlineargs.cpp (arbetskopia)
@@ -140,6 +140,7 @@
const KAboutData *KCmdLineArgs::about = 0;
bool KCmdLineArgs::parsed = false;
bool KCmdLineArgs::ignoreUnknown = false;
+KCmdLineArgs::StdCmdLineArgs KCmdLineArgs::mStdargs = 0;
//
// Static functions
@@ -224,6 +225,7 @@
if (stdargs & KCmdLineArgs::CmdLineArgKDE) {
KCmdLineArgs::addCmdLineOptions(kde_options, "KDE", "kde");
}
+ mStdargs = stdargs;
}
void
@@ -713,6 +715,12 @@
if( qt_argc != -1 )
return &qt_argc;
+ if (!(mStdargs & KCmdLineArgs::CmdLineArgQt))
+ {
+ qt_argc = 2;
+ return &qt_argc;
+ }
+
KCmdLineArgs *args = parsedArgs("qt");
Q_ASSERT(args); // No qt options have been added!
if (!argv)
@@ -744,6 +752,15 @@
if( qt_argv != NULL )
return &qt_argv;
+ if (!(mStdargs & KCmdLineArgs::CmdLineArgQt))
+ {
+ qt_argv = new char*[2];
+ qt_argv[0] = qstrdup(appName());
+ qt_argv[1] = 0;
+
+ return &qt_argv;
+ }
+
KCmdLineArgs *args = parsedArgs("qt");
Q_ASSERT(args); // No qt options have been added!
if (!argv)
Index: kcmdlineargs.h
===================================================================
--- kcmdlineargs.h (revision 492369)
+++ kcmdlineargs.h (arbetskopia)
@@ -688,6 +688,7 @@
static bool ignoreUnknown; // Ignore unknown options and arguments
static char *mCwd; // Current working directory. Important for KUnqiueApp!
static bool parseArgs;
+ static StdCmdLineArgs mStdargs;
class Private;
Private *d;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic