Browse Source

Merge topic 'cmake-gui-file-dialog-crash' into release-3.19

5f782119c8 cmake-gui: Restore workaround for crash in file dialog

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5472
Brad King 5 years ago
parent
commit
dd8c91a4f3
2 changed files with 14 additions and 0 deletions
  1. 13 0
      Source/QtDialog/QCMakeCacheView.cxx
  2. 1 0
      Source/QtDialog/QCMakeCacheView.h

+ 13 - 0
Source/QtDialog/QCMakeCacheView.cxx

@@ -642,6 +642,19 @@ bool QCMakeCacheModelDelegate::editorEvent(QEvent* e,
   return success;
 }
 
+bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt)
+{
+  // FIXME: This filter avoids a crash when opening a file dialog
+  // with the '...' button on a cache entry line in the GUI.
+  // Previously this filter was commented as a workaround for Qt issue 205903,
+  // but that was fixed in Qt 4.5.0 and the crash still occurs as of Qt 5.14
+  // without this filter.  This needs further investigation.
+  if (evt->type() == QEvent::FocusOut && this->FileDialogFlag) {
+    return false;
+  }
+  return QItemDelegate::eventFilter(object, evt);
+}
+
 void QCMakeCacheModelDelegate::setModelData(QWidget* editor,
                                             QAbstractItemModel* model,
                                             const QModelIndex& index) const

+ 1 - 0
Source/QtDialog/QCMakeCacheView.h

@@ -143,6 +143,7 @@ public:
   bool editorEvent(QEvent* event, QAbstractItemModel* model,
                    const QStyleOptionViewItem& option,
                    const QModelIndex& index);
+  bool eventFilter(QObject* object, QEvent* event);
   void setModelData(QWidget* editor, QAbstractItemModel* model,
                     const QModelIndex& index) const;
   QSize sizeHint(const QStyleOptionViewItem& option,