why the QfileDialog works differently on different machines?
Hi,
In my application , I use the static function of QFileDialog to get open file or save file .
Now the application runs well on some machines, but on others , as soon as calling the function to get open file , the dialog pops up and soon the whole application crashes . OR after selecting a file , click the OK button , the application crashes .
what kind of reasons could cause this problem ?how to fix it ?
My application is based on QT4.
Thanks .
Nicho
Re: why the QfileDialog works differently on different machines?
Quote:
Originally Posted by
Nicho
Hi,
In my application , I use the static function of QFileDialog to get open file or save file .
Now the application runs well on some machines, but on others , as soon as calling the function to get open file , the dialog pops up and soon the whole application crashes . OR after selecting a file , click the OK button , the application crashes .
what kind of reasons could cause this problem ?how to fix it ?
My application is based on QT4.
Thanks .
Nicho
This is because the dialogue box pops up too early. I think you also go for warning/error message boxes right before it. Try to control the outcome of succeeding dialogues.
I do not know how you implemented this, but as an example I take the below code:
Code:
void CMain::doMain() {
// check that the message box is working as expected!
QMessageBox::information(nullptr,
"Test Msgbox", tr
("Qt Version: %1").
arg(QT_VERSION_STR
));
// THIS QFILEDIALOG BREAKS SOMETHING!
// comment the next line out to see everything working normal!
// you'll hear the message box sound, but don't see anything
QMessageBox::warning(nullptr,
"Test Msgbox 2",
"Hi, I'm another msg box");
// the error msg will show up, but it will stay "unusable" in the background
// also the program will execute the following file dialog at the same time without waiting
ErrMsg.setModal(true);
ErrMsg.showMessage(tr("This is some sort of error message"));
ErrMsg.exec();
// this pops up too early
cout << "doMain() done. Time to quit()." << endl;
qApp->quit();
}//end method
Re: why the QfileDialog works differently on different machines?
Quote:
Originally Posted by
saman_artorious
This is because the dialogue box pops up too early. I think you also go for warning/error message boxes right before it. Try to control the outcome of succeeding dialogues.
I do not know how you implemented this, but as an example I take the below code:
Code:
void CMain::doMain() {
// check that the message box is working as expected!
QMessageBox::information(nullptr,
"Test Msgbox", tr
("Qt Version: %1").
arg(QT_VERSION_STR
));
// THIS QFILEDIALOG BREAKS SOMETHING!
// comment the next line out to see everything working normal!
// you'll hear the message box sound, but don't see anything
QMessageBox::warning(nullptr,
"Test Msgbox 2",
"Hi, I'm another msg box");
// the error msg will show up, but it will stay "unusable" in the background
// also the program will execute the following file dialog at the same time without waiting
ErrMsg.setModal(true);
ErrMsg.showMessage(tr("This is some sort of error message"));
ErrMsg.exec();
// this pops up too early
cout << "doMain() done. Time to quit()." << endl;
qApp->quit();
}//end method
Thank you , saman
I call the getOpenFileName() in a slot which is connected to a menu item . In that slot, no other dialogues need to be popped up.
So when I try to show the dialogue , the main window has been shown out very well .
And it can be running in proper way on some machines of my workmates and mine , but on other machines , it crashes .
Why exists this difference ?
Nicho
Re: why the QfileDialog works differently on different machines?
Quote:
Originally Posted by
Nicho
Hi,
In my application , I use the static function of QFileDialog to get open file or save file .
Now the application runs well on some machines, but on others , as soon as calling the function to get open file , the dialog pops up and soon the whole application crashes . OR after selecting a file , click the OK button , the application crashes .
what kind of reasons could cause this problem ?how to fix it ?
My application is based on QT4.
Show us a debugger backtrace from this crash.
Re: why the QfileDialog works differently on different machines?
Quote:
Originally Posted by
wysota
Show us a debugger backtrace from this crash.
Hi, wysota
The backtrace is like this:
Code:
#0 xmlParserInputShrink (in=0xfbb7d50) at parser.c:268
#1 0x00002b718fafcde5 in xmlParseCharDataComplex (ctxt=0xfbb69f0, cdata=0) at parser.c:4201
#2 0x0000003f11e46c0f in xmlParseChunk () from /usr/lib64/libxml2.so.2
#3 0x0000003f11ed72b1 in ?? () from /usr/lib64/libxml2.so.2
#4 0x0000003f11ed877a in xmlTextReaderRead () from /usr/lib64/libxml2.so.2
#5 0x0000003f1622faef in ?? () from /usr/lib64/libgnomevfs-2.so.0
#6 0x0000003f1622fdaa in ?? () from /usr/lib64/libgnomevfs-2.so.0
#7 0x0000003f1622fe49 in gnome_vfs_mime_get_value () from /usr/lib64/libgnomevfs-2.so.0
#8 0x0000003f1622d4cf in gnome_vfs_mime_get_icon () from /usr/lib64/libgnomevfs-2.so.0
#9 0x0000003f18662394 in gnome_icon_lookup () from /usr/lib64/libgnomeui-2.so.0
#10 0x00002aaab1dd10c0 in ?? () from /usr/lib64/gtk-2.0/2.10.0/filesystems/libgnome-vfs.so
#11 0x0000003f0e4e96c0 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#12 0x0000003f0e4e9771 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#13 0x0000003f0e4e9b43 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#14 0x0000003f0b40b08a in g_closure_invoke () from /lib64/libgobject-2.0.so.0
#15 0x0000003f0b41b2ed in ?? () from /lib64/libgobject-2.0.so.0
#16 0x0000003f0b41c748 in g_signal_emit_valist () from /lib64/libgobject-2.0.so.0
#17 0x0000003f0b41e300 in g_signal_emit_by_name () from /lib64/libgobject-2.0.so.0
#18 0x00002aaab1dd23bb in ?? () from /usr/lib64/gtk-2.0/2.10.0/filesystems/libgnome-vfs.so
#19 0x0000003f1622a063 in ?? () from /usr/lib64/libgnomevfs-2.so.0
#20 0x0000003f1622a793 in ?? () from /usr/lib64/libgnomevfs-2.so.0
#21 0x0000003f0b02cdb4 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#22 0x0000003f0b02fc0d in ?? () from /lib64/libglib-2.0.so.0
#23 0x0000003f0b02ff1a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#24 0x0000003f0e4b88da in gtk_dialog_run () from /usr/lib64/libgtk-x11-2.0.so.0
#25 0x00002b7191fac9d5 in ?? () from /qt4/lib/libQtGui.so.4
#26 0x000000000fb3d820 in ?? ()
#27 0x00002b71926fe310 in vtable for QWidget () from /qt4/lib/libQtGui.so.4
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Re: why the QfileDialog works differently on different machines?
Well... you can see the crash occurs within libxml2 which is called by gnome libraries. I don't think Qt has anything to do with this. Does the crash occur only on machines with a gnome-based system?
Re: why the QfileDialog works differently on different machines?
Quote:
Originally Posted by
wysota
Well... you can see the crash occurs within libxml2 which is called by gnome libraries. I don't think Qt has anything to do with this. Does the crash occur only on machines with a gnome-based system?
No , wysota
The system of all our machines is GNOME-based. And even on the same machine with different account, some is OK, other makes it crash.
Nicho
Re: why the QfileDialog works differently on different machines?
It seems like this is an issue related to user settings. I don't think you can do anything with your source code to fix it other than using non-native file dialog.
Re: why the QfileDialog works differently on different machines?
Quote:
Originally Posted by
wysota
It seems like this is an issue related to user settings. I don't think you can do anything with your source code to fix it other than using non-native file dialog.
wysota,
You mean, I need to create my own dialog for selecting open or save file, not using QFileDialog?
Nicho
Re: why the QfileDialog works differently on different machines?
No, I mean you should set the QFileDialog::DontUseNativeDialog option on the dialog.
Re: why the QfileDialog works differently on different machines?
No.
You can pass QFileDialog::DontUseNativeDialog as an option to the static functions.
Of course that disables platform integration for the respective call.
Are those system identical? I.e. same OS, same version, same update status?
Does it happen on a new user account on those machine that have the problem?
Cheers,
_
Re: why the QfileDialog works differently on different machines?
Thanks , wysota
Thanks , anda_skoa
I have set the option , and the application is OK .
But , another similar problem is :
in my mate’s application, we found that if we include a pri file which contains some library link, then the application will crash. and the crash occurs also at XML2,the backtrace is even the same to mine. If we remove the including, the QFileDialog works well. I tried to set the option, but it does not work.
Nicho
Re: why the QfileDialog works differently on different machines?
Maybe GTK (in your original backtrace) or some other library is linked to a different version of libxml2 then the one you are trying to add through the .pri file
Cheers,
_