qt-interest@trolltech.com
[Top] [All Lists]

[Qt 4] QApplication/QtSingleApplication problem with argc()

Subject: [Qt 4] QApplication/QtSingleApplication problem with argc()
From: <>
Date: Tue, 26 Jul 2005 12:44:46 +0200
Hi all

It seems that I have a problem using the argc() call of QApplication
(via QtSingleApplication). Using Qt 4.0.0, WinXP.

I create the QtSingleApplication as below:

int main( int argc, char ** argv )                              // argc
= 1
{
        CMainProcessBase pMPBase( argc, argv );

        if(     pMPBase.isRunning() ) {
                return 0;
        }
        else {
                // init the QtSingleApplication class
                int iArgCount = pMPBase.argc();    // is about 1244892

                pMPBase.initialize();

                iArgCount = pMPBase.argc();          // no difference
                qWarning(pMPBase.argv()[0]);         // correct

                QTimer::singleShot(0, &pMPBase, SLOT(execute()));
        }
        return pMPBase.exec();
}

//////////////////////////////////////////////////////////////////////

CMainProcessBase::CMainProcessBase( int argc, char ** argv )
: QtSingleApplication("MP", argc, argv)
{
}

void CMainProcessBase::execute()
{
        int iArgCount = this->argc();                              // is
1244892

        iArgCount = QCoreApplication::instance()->argc(); // same here

        qWarning((this->argv()[1]));                               //
this is OK

        if(argc() > 2 )
                QDir::setCurrent(argv()[2]);
        else
                QDir::setCurrent(applicationDirPath());
...
}

Has anybody else experienced that problem and what was your solution?
Currently I copy the argc to a member and use that one.

Any other suggestions, please?

regards,
Michael Soukup

<Prev in Thread] Current Thread [Next in Thread>