Fix file dialogs with Qt 5.2.0 and later.

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.
This commit is contained in:
Enrico Forestieri 2013-12-24 17:21:56 +01:00
parent 49d3557d0c
commit 581400937d

View File

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