]> git.lyx.org Git - features.git/commitdiff
Fix file dialogs with Qt 5.2.0 and later.
authorEnrico Forestieri <forenr@lyx.org>
Tue, 24 Dec 2013 16:21:56 +0000 (17:21 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 24 Dec 2013 16:21:56 +0000 (17:21 +0100)
See https://bugreports.qt-project.org/browse/QTBUG-34132

   * [QTBUG-34132] QFileDialog does no longer instantiate widgets if a
     native dialog will be used instead.  Therefore some accessors
     which previously returned unused objects will now return null.
     As before, you can set the DontUseNativeDialog option to ensure
     that widgets will be created and used instead.

Seemingly, Qt uses native dialogs by default starting from version 5.2.0.
When trying to open a file dialog, LyX segfaults in release mode, whereas
Qt asserts in debug mode:
ASSERT failure in QList<T>::at: "index out of range",
file /usr/local/qt/5.2.0/include/QtCore/qlist.h, line 472

This is avoided by explicitly setting the DontUseNativeDialog option
in the code path selected by *not* setting USE_NATIVE_FILEDIALOG.
This option was introduced in Qt 4.5, which is the minimum required
for compiling LyX. So, it is not protected by a preprocessor macro.

src/frontends/qt4/LyXFileDialog.cpp

index 2bc7ba1a030d8eb6e2e0d2d26932c51a351362e4..edb15f0887b67f34d0308049fb96fd129a68f0e2 100644 (file)
@@ -51,6 +51,7 @@ LyXFileDialog::LyXFileDialog(QString const & title,
 {
        setNameFilters(filters);
        setWindowTitle(title);
+       setOption(QFileDialog::DontUseNativeDialog);
 
        QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();