# HG changeset patch # User koda # Date 1308479694 -7200 # Node ID 0bbdd47522b9eeb2830271f59b3877f5c1e7977f # Parent e3fada9358b0a54ebfb2c9e53b165db6ff47578a passing by reference... my darkest enemy actual reason below: In your case (without reference) the compiler generates a temporary object (int) for the first argument of your MyApplication constructor. You pass this temporary int to QApplication’s constructor (with int reference), which saves the address of this reference. Once your MyApplication constructor is done the temporary int is destroyed but QApplication still has its address. diff -r e3fada9358b0 -r 0bbdd47522b9 QTfrontend/HWApplication.cpp --- a/QTfrontend/HWApplication.cpp Sun Jun 19 00:49:13 2011 +0200 +++ b/QTfrontend/HWApplication.cpp Sun Jun 19 12:34:54 2011 +0200 @@ -21,8 +21,8 @@ #include "hwform.h" -HWApplication::HWApplication(int argc, char **argv): - QApplication(argc,argv) +HWApplication::HWApplication(int &argc, char **argv): + QApplication(argc, argv) { } diff -r e3fada9358b0 -r 0bbdd47522b9 QTfrontend/HWApplication.h --- a/QTfrontend/HWApplication.h Sun Jun 19 00:49:13 2011 +0200 +++ b/QTfrontend/HWApplication.h Sun Jun 19 12:34:54 2011 +0200 @@ -29,11 +29,10 @@ { Q_OBJECT public: - HWApplication(int argc, char **argv); + HWApplication(int &argc, char **argv); ~HWApplication() {}; HWForm *form; - QString *fileToLoad; protected: bool event(QEvent *); }; diff -r e3fada9358b0 -r 0bbdd47522b9 QTfrontend/main.cpp --- a/QTfrontend/main.cpp Sun Jun 19 00:49:13 2011 +0200 +++ b/QTfrontend/main.cpp Sun Jun 19 12:34:54 2011 +0200 @@ -57,9 +57,6 @@ QStringList arguments = app.arguments(); QMap parsedArgs; -#ifndef __APPLE__ -//HACK: it's difficult/rarely done to use command line args on macs anyways -// but why does this section of code make the app crash when opening a file? { QList::iterator i = arguments.begin(); while(i != arguments.end()) { @@ -74,7 +71,6 @@ } } } -#endif if(parsedArgs.contains("data-dir")) { QFileInfo f(parsedArgs["data-dir"]); diff -r e3fada9358b0 -r 0bbdd47522b9 QTfrontend/pageoptions.cpp --- a/QTfrontend/pageoptions.cpp Sun Jun 19 00:49:13 2011 +0200 +++ b/QTfrontend/pageoptions.cpp Sun Jun 19 12:34:54 2011 +0200 @@ -244,11 +244,13 @@ BtnAssociateFiles->setEnabled(!custom_data && !custom_config); MiscLayout->addWidget(BtnAssociateFiles, 5, 0, 1, 2); -#ifdef __APPLE__ && SPARKLE_ENABLED +#ifdef __APPLE__ +#ifdef SPARKLE_ENABLED CBAutoUpdate = new QCheckBox(groupMisc); CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); MiscLayout->addWidget(CBAutoUpdate, 6, 0, 1, 3); #endif +#endif gbTBLayout->addWidget(groupMisc, 2, 0); }