QFileDialog The program has unexpectedly finished.



  • Hi,
    i have programing QFileDialog, when i press button i want to open the file dialog, when i run my program i got following messages,

    (imagecapture:14396): Gtk-WARNING **: Invalid input string

    (imagecapture:14396): Gtk-WARNING **: Invalid input string
    The program has unexpectedly finished.

    here i paste my code

    void MainWindow::on_sendto_clicked()
    {
    QString file_neme = QFileDialog::getExistingDirectory(this,tr("Open Directory"),"/home/malar/Documents/",QFileDialog::ShowDirsOnly|QFileDialog::DontUseNativeDialog);
    }

    i am using qt 5.8 and ubuntu 14.04 64bit, could you help me to solve this message.

    thanking you,



  • Hi,
    there is nothing wrong with the code you posted (I've just tested it and it worked). The problem has to be somewhere in the environment in which you start your application.
    -Michael.



  • Hi,
    I encoutered a very similair issues and haven't been able to explain it.
    I "solved" it using the non static QFileDialog
    Dialog open method :

    it would be something like this :

    void MainWindow::on_sendto_clicked(void)
    {
    	QFileDialog *dialog = new QFileDialog;
    	dialog->setDirectory("/home/malar/Documents/");
    	dialog->setFileMode(QFileDialog::DirectoryOnly);
    	dialog->setOptions(QFileDialog::DontUseSheet
    					   | QFileDialog::DontUseCustomDirectoryIcons
    					   | QFileDialog::ReadOnly
    					   | QFileDialog::HideNameFilterDetails);
    	dialog->open(this, SLOT(on_sendto_clicked(const QString&)));
    }
    
    void MainWindow::on_sendto_clicked(const QString& file_neme )
    {
       // your process
    }

  • Lifetime Qt Champion

    Hi,

    @eti_nne, you have a memory leak here. Your QFileDialog instance is never deleted.



  • @SGaist
    Indeed. My bad. I forgot a line :

    dialog->setAttribute(Qt::WA_DeleteOnClose);
    

    Copy pasting is definitely an art :)



  • Hi all,

    Thanks for your replay ,

    It is working fine for me, but i have added don't use native dialog see here i attached that line,

    dialog->setOptions(QFileDialog::DontUseSheet
    | QFileDialog::DontUseCustomDirectoryIcons
    | QFileDialog::ReadOnly
    | QFileDialog::HideNameFilterDetails
    | QFileDialog::DontUseNativeDialog);

    Again i got same problem "The program has unexpectedly finished."

    Thanking You,


  • Lifetime Qt Champion

    Can you show a stack trace of your crash ?



  • Hi,

    i am new to qt where i can find this stack trace on qt creator.

    thank you



  • @Linux-BABU
    if you are using qtcreator, just press F5 to run the program in debug mode, when your program crash, it will show the stack trace on the bottom



  • Hi

    This is my stack trace

    1 ?? 0x7fffe0320526
    2 ?? 0x7fffe032762e
    3 ?? 0x7fffdb8448db
    4 ?? 0x7fffdb8448f9
    5 g_main_context_dispatch 0x7ffff1615ce5
    6 ?? 0x7ffff1616048
    7 g_main_context_iteration 0x7ffff16160ec
    8 QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) 0x7ffff47f4cbf
    9 QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) 0x7ffff47a29ca
    10 QCoreApplication::exec() 0x7ffff47aa9f4
    11 main main.cpp 10 0x40e488

    Thank you


  • Lifetime Qt Champion

    Which Linux distribution are you on ?



  • @SGaist

    ubuntu 14.04 64bit



  • Hi, I using qml FileDialog on Ubuntu 16.04, Qt 5.8 ,it have same problem with message 'Gtk-WARNING **: Invalid input string' then may app is not respond, any one can help me fix this .


  • Moderators

    @kd_wala Most probably nobody will be able to help if you do not show your code.
    My guess is that this GTK warning isn't the actual problem.



  • I'm getting the exact same error. I'm using Qt 5.8 on Debian 8 with GNOME 3.14.1. It crashes no matter what kind of file or directory dialog I open, if I pass the DontUseNativeDialog option flag. (I would be fine with native dialog, but it seemed the ShowDirsOnly flag was being ignored, so I tried using the Qt dialogs and here we are.)

    Here is a detailed stack trace from the point where a static dialog method is called:

    #0  0x00007fffecf75c16 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
    No symbol table info available.
    #1  0x00007fffecf7a56a in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
    No symbol table info available.
    #2  0x00007fffec60b4bb in ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
    No symbol table info available.
    #3  0x00007fffec60b4d9 in ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
    No symbol table info available.
    #4  0x00007ffff2949b6d in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    No symbol table info available.
    #5  0x00007ffff2949f48 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    No symbol table info available.
    #6  0x00007ffff2949ffc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
    No symbol table info available.
    #7  0x00007ffff69b3cbf in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
    No symbol table info available.
    #8  0x00007ffff69619ca in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
    No symbol table info available.
    #9  0x00007ffff78d5a07 in QDialog::exec() () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Widgets.so.5
    No symbol table info available.
    #10 0x00007ffff78e6ecd in QFileDialog::getSaveFileUrl(QWidget*, QString const&, QUrl const&, QString const&, QString*, QFlags<QFileDialog::Option>, QStringList const&) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Widgets.so.5
    No symbol table info available.
    #11 0x00007ffff78e6f8a in QFileDialog::getSaveFileName(QWidget*, QString const&, QString const&, QString const&, QString*, QFlags<QFileDialog::Option>) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Widgets.so.5
    No symbol table info available.
    

  • Lifetime Qt Champion

    Hi @calc84maniac please install the debug symbol packages of these libraries, it will allow to get a better stack trace.



  • @SGaist Sure. If you need me to get Qt 5.8.0 symbols too, please point me in the right direction since there don't seem to be any packages readily available.

    #0  update_current_folder_get_info_cb (cancellable=0xaedc40, info=0x0, error=0xa7aca0, user_data=0x9df380) at /tmp/buildd/gtk+3.0-3.14.5/./gtk/gtkfilechooserwidget.c:4268
            cancelled = 1
            data = 0x9df380
            impl = 0xa1c3b0
            priv = 0x0
    #1  0x00007fffecf7a56a in query_info_callback (source_object=<optimized out>, result=<optimized out>, user_data=0xaeee20) at /tmp/buildd/gtk+3.0-3.14.5/./gtk/gtkfilesystem.c:419
            async_data = 0xaeee20
            error = 0xa7aca0
            file_info = 0x0
            file = <optimized out>
    #2  0x00007fffec60b4bb in g_task_return_now (task=0xaeb390) at /build/glib2.0-y6934K/glib2.0-2.42.1/./gio/gtask.c:1077
    No locals.
    #3  0x00007fffec60b4d9 in complete_in_idle_cb (task=0xaeb390) at /build/glib2.0-y6934K/glib2.0-2.42.1/./gio/gtask.c:1086
    No locals.
    #4  0x00007ffff2949b6d in g_main_dispatch (context=0x7fffe8002450) at /build/glib2.0-y6934K/glib2.0-2.42.1/./glib/gmain.c:3111
            dispatch = 0x7ffff29466c0 <g_idle_dispatch>
            prev_source = 0x7b13e0
            was_in_call = 0
            user_data = 0xaeb390
            callback = 0x7fffec60b4d0 <complete_in_idle_cb>
            cb_funcs = <optimized out>
            cb_data = 0x7fffc0001190
            need_destroy = <optimized out>
            source = 0x7fffc0001120
            current = 0x6bae40
            i = 11
    #5  g_main_context_dispatch (context=context@entry=0x7fffe8002450) at /build/glib2.0-y6934K/glib2.0-2.42.1/./glib/gmain.c:3710
    No locals.
    #6  0x00007ffff2949f48 in g_main_context_iterate (context=context@entry=0x7fffe8002450, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at /build/glib2.0-y6934K/glib2.0-2.42.1/./glib/gmain.c:3781
            max_priority = 0
            timeout = 0
            some_ready = 1
            nfds = <optimized out>
            allocated_nfds = 5
            fds = 0x97b980
    #7  0x00007ffff2949ffc in g_main_context_iteration (context=0x7fffe8002450, may_block=1) at /build/glib2.0-y6934K/glib2.0-2.42.1/./glib/gmain.c:3842
            retval = <optimized out>
    #8  0x00007ffff69b3cbf in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
    No symbol table info available.
    #9  0x00007ffff69619ca in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Core.so.5
    No symbol table info available.
    #10 0x00007ffff78d5a07 in QDialog::exec() () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Widgets.so.5
    No symbol table info available.
    #11 0x00007ffff78e6d5f in QFileDialog::getSaveFileUrl(QWidget*, QString const&, QUrl const&, QString const&, QString*, QFlags<QFileDialog::Option>, QStringList const&) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Widgets.so.5
    No symbol table info available.
    #12 0x00007ffff78e6f8a in QFileDialog::getSaveFileName(QWidget*, QString const&, QString const&, QString const&, QString*, QFlags<QFileDialog::Option>) () from /home/user/Qt5.8.0/5.8/gcc_64/lib/libQt5Widgets.so.5
    No symbol table info available.
    


  • I did a little research on my own, and it looks like this is a reference counting bug in GTK+, which was fixed in GTK+ 3.15.5. The bug tracker entry is here: https://bugzilla.gnome.org/show_bug.cgi?id=725164

    It appears that Firefox had to put in a workaround for this very issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1166741

    I'm not sure if it's worth putting a workaround in Qt or not, but it would be nice to not have segfaults.


  • Lifetime Qt Champion

    Since you could gather some additional hints, I'd say it would be worth double checking the bug report system to check if it's something known, if so add your findings otherwise open a new report with what you already found.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.