Results 1 to 13 of 13

Thread: why the QfileDialog works differently on different machines?

  1. #1
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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

  2. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: why the QfileDialog works differently on different machines?

    Quote Originally Posted by Nicho View Post
    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:

    Qt Code:
    1. void CMain::doMain() {
    2. // check that the message box is working as expected!
    3. QMessageBox::information(nullptr, "Test Msgbox", tr("Qt Version: %1").arg(QT_VERSION_STR));
    4.  
    5. // THIS QFILEDIALOG BREAKS SOMETHING!
    6. // comment the next line out to see everything working normal!
    7. QFileDialog::getOpenFileName(nullptr, "Open some file", QString(), tr("All files (*.*)"), nullptr, QFileDialog::ReadOnly);
    8.  
    9. // you'll hear the message box sound, but don't see anything
    10. QMessageBox::warning(nullptr, "Test Msgbox 2", "Hi, I'm another msg box");
    11.  
    12. // the error msg will show up, but it will stay "unusable" in the background
    13. // also the program will execute the following file dialog at the same time without waiting
    14. QErrorMessage ErrMsg;
    15. ErrMsg.setModal(true);
    16. ErrMsg.showMessage(tr("This is some sort of error message"));
    17. ErrMsg.exec();
    18.  
    19. // this pops up too early
    20. QFileDialog::getOpenFileName(nullptr, "Open another file", QString(), tr("All files (*.*)"), nullptr, QFileDialog::ReadOnly);
    21.  
    22. cout << "doMain() done. Time to quit()." << endl;
    23. qApp->quit();
    24. }//end method
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: why the QfileDialog works differently on different machines?

    Quote Originally Posted by saman_artorious View Post
    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:

    Qt Code:
    1. void CMain::doMain() {
    2. // check that the message box is working as expected!
    3. QMessageBox::information(nullptr, "Test Msgbox", tr("Qt Version: %1").arg(QT_VERSION_STR));
    4.  
    5. // THIS QFILEDIALOG BREAKS SOMETHING!
    6. // comment the next line out to see everything working normal!
    7. QFileDialog::getOpenFileName(nullptr, "Open some file", QString(), tr("All files (*.*)"), nullptr, QFileDialog::ReadOnly);
    8.  
    9. // you'll hear the message box sound, but don't see anything
    10. QMessageBox::warning(nullptr, "Test Msgbox 2", "Hi, I'm another msg box");
    11.  
    12. // the error msg will show up, but it will stay "unusable" in the background
    13. // also the program will execute the following file dialog at the same time without waiting
    14. QErrorMessage ErrMsg;
    15. ErrMsg.setModal(true);
    16. ErrMsg.showMessage(tr("This is some sort of error message"));
    17. ErrMsg.exec();
    18.  
    19. // this pops up too early
    20. QFileDialog::getOpenFileName(nullptr, "Open another file", QString(), tr("All files (*.*)"), nullptr, QFileDialog::ReadOnly);
    21.  
    22. cout << "doMain() done. Time to quit()." << endl;
    23. qApp->quit();
    24. }//end method
    To copy to clipboard, switch view to plain text mode 
    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why the QfileDialog works differently on different machines?

    Quote Originally Posted by Nicho View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: why the QfileDialog works differently on different machines?

    Quote Originally Posted by wysota View Post
    Show us a debugger backtrace from this crash.
    Hi, wysota

    The backtrace is like this:

    Qt Code:
    1. #0 xmlParserInputShrink (in=0xfbb7d50) at parser.c:268
    2. #1 0x00002b718fafcde5 in xmlParseCharDataComplex (ctxt=0xfbb69f0, cdata=0) at parser.c:4201
    3. #2 0x0000003f11e46c0f in xmlParseChunk () from /usr/lib64/libxml2.so.2
    4. #3 0x0000003f11ed72b1 in ?? () from /usr/lib64/libxml2.so.2
    5. #4 0x0000003f11ed877a in xmlTextReaderRead () from /usr/lib64/libxml2.so.2
    6. #5 0x0000003f1622faef in ?? () from /usr/lib64/libgnomevfs-2.so.0
    7. #6 0x0000003f1622fdaa in ?? () from /usr/lib64/libgnomevfs-2.so.0
    8. #7 0x0000003f1622fe49 in gnome_vfs_mime_get_value () from /usr/lib64/libgnomevfs-2.so.0
    9. #8 0x0000003f1622d4cf in gnome_vfs_mime_get_icon () from /usr/lib64/libgnomevfs-2.so.0
    10. #9 0x0000003f18662394 in gnome_icon_lookup () from /usr/lib64/libgnomeui-2.so.0
    11. #10 0x00002aaab1dd10c0 in ?? () from /usr/lib64/gtk-2.0/2.10.0/filesystems/libgnome-vfs.so
    12. #11 0x0000003f0e4e96c0 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
    13. #12 0x0000003f0e4e9771 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
    14. #13 0x0000003f0e4e9b43 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
    15. #14 0x0000003f0b40b08a in g_closure_invoke () from /lib64/libgobject-2.0.so.0
    16. #15 0x0000003f0b41b2ed in ?? () from /lib64/libgobject-2.0.so.0
    17. #16 0x0000003f0b41c748 in g_signal_emit_valist () from /lib64/libgobject-2.0.so.0
    18. #17 0x0000003f0b41e300 in g_signal_emit_by_name () from /lib64/libgobject-2.0.so.0
    19. #18 0x00002aaab1dd23bb in ?? () from /usr/lib64/gtk-2.0/2.10.0/filesystems/libgnome-vfs.so
    20. #19 0x0000003f1622a063 in ?? () from /usr/lib64/libgnomevfs-2.so.0
    21. #20 0x0000003f1622a793 in ?? () from /usr/lib64/libgnomevfs-2.so.0
    22. #21 0x0000003f0b02cdb4 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
    23. #22 0x0000003f0b02fc0d in ?? () from /lib64/libglib-2.0.so.0
    24. #23 0x0000003f0b02ff1a in g_main_loop_run () from /lib64/libglib-2.0.so.0
    25. #24 0x0000003f0e4b88da in gtk_dialog_run () from /usr/lib64/libgtk-x11-2.0.so.0
    26. #25 0x00002b7191fac9d5 in ?? () from /qt4/lib/libQtGui.so.4
    27. #26 0x000000000fb3d820 in ?? ()
    28. #27 0x00002b71926fe310 in vtable for QWidget () from /qt4/lib/libQtGui.so.4
    29. Backtrace stopped: previous frame inner to this frame (corrupt stack?)
    To copy to clipboard, switch view to plain text mode 
    Last edited by Nicho; 5th August 2013 at 04:01.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: why the QfileDialog works differently on different machines?

    Quote Originally Posted by wysota View Post
    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

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: why the QfileDialog works differently on different machines?

    Quote Originally Posted by wysota View Post
    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

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why the QfileDialog works differently on different machines?

    No, I mean you should set the QFileDialog::DontUseNativeDialog option on the dialog.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: why the QfileDialog works differently on different machines?

    No.
    You can pass QFileDialog:ontUseNativeDialog 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,
    _

  12. #12
    Join Date
    Jun 2013
    Posts
    56
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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

  13. #13
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

Similar Threads

  1. Replies: 3
    Last Post: 6th July 2011, 07:59
  2. Derived class from QLineEdit is behaving differently.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 21st January 2011, 09:40
  3. QPushButton appears differently
    By gianhut in forum Qt Tools
    Replies: 4
    Last Post: 5th January 2009, 23:08
  4. QPalette works differently on windows and linux
    By babu198649 in forum Newbie
    Replies: 3
    Last Post: 6th March 2008, 08:27
  5. Replies: 13
    Last Post: 18th February 2008, 01:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.