Review Request: Fix KCmdLineArgs so that it doesn't strip the path from argv[0] but still display the appname without path where needed

George Kiagiadakis at
Mon Oct 19 22:14:45 BST 2009

This is an automatically generated e-mail. To reply, visit:

Review request for kdelibs.


This patch makes KCmdLineArgs to use a separate variable to hold the app name (without the path) instead of striping the path from argv[0]. The path in argv[0] might still be useful, for example for use in QCoreApplication::applicationFilePath(). In addition, when striping the path from the app name, use QDir::separator() to make it work correctly on windows.

For the reason why I am doing this, please read


  /trunk/KDE/kdelibs/kdecore/kernel/kcmdlineargs.cpp 1037603 



I have tested the patch on linux, freebsd and windows using the following testcase:

int main(int argc, char **argv)
    kDebug() << argv[0];

    KAboutData a("test", 0, KLocalizedString(), "0.1");
    KCmdLineArgs::init(argc, argv, &a);
    KApplication app(false);

    kDebug() << argv[0];
    kDebug() << QCoreApplication::applicationDirPath();
    kDebug() << QCoreApplication::applicationFilePath();
    kDebug() << KCmdLineArgs::appName();

The result is as expected on all platforms: argv[0] doesn't change, appName() returns the application's name without the path and applicationDirPath()/applicationFilePath() return correct paths.



More information about the kde-core-devel mailing list