PDA

View Full Version : QFileDialog



skizzik
23rd August 2011, 13:58
In my program I use a QFileDialog to let the user pick a file to open. This works perfect as it should both when I start the program from inside Qt and when I start the app-bundle in finder (I'm sitting on a mac).

Now I want to deploy the application so it can be used on other computers without Qt installed. I use a script that copies some Qt frameworks (core and gui) to inside the app-bundle and then use install_name_tool. I have used the exact same script for many other programs before and it works perfect.

The final app-bundle works fine to start. When I click the button to open the filedialog, it shows as it should. But when I close the dialog window, the program crashes with a EXC_BAD_ACCESS. It doesn't matter if I chose a file or not, it always crashes directly after I try to close the file dialog. I have commented out all the other code for the button-click so it must be something with the filedialog.

The function is now:

void MainWindow::button_clicked()
{
QString name = QFileDialog::getOpenFileName(this, "Open File");
}

Any ideas?

squidge
23rd August 2011, 14:12
I doubt it would be something with filedialog, maybe you are overwriting a buffer somewhere?

skizzik
23rd August 2011, 14:40
Thanks for the answer! How am I overwriting a buffer do you think?

If I change the function to:

void MainWindow::button_clicked()
{
QString name = QFileDialog::getOpenFileName(this, "Open File");
while(true);
}

the program still crashes promptly after I close the dialog-window. If i run it before copying the frameworks it freezes of course. And as I said, it works perfect before I move the frameworks to inside the bundle. And all previous programs works perfect after running the script, many of them use QFileDialog too.

The script just copies the frameworks to the bundle and then run a few lines like:
install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore myapp.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore
install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore myapp.app/Contents/MacOs/balans

skizzik
24th August 2011, 14:13
Nobody who has any idea of ​​what might be causing the error?

Rachol
24th August 2011, 14:46
There might be problem with libraries you are using. Make sure they are correct versions. Try to run it against both release and debug versions.