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.
--- 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)
{
}
--- 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 *);
};
--- 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<QString, QString> 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<QString>::iterator i = arguments.begin();
while(i != arguments.end()) {
@@ -74,7 +71,6 @@
}
}
}
-#endif
if(parsedArgs.contains("data-dir")) {
QFileInfo f(parsedArgs["data-dir"]);
--- 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);
}