diff options
author | Brad King <brad.king@kitware.com> | 2020-11-05 19:50:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-05 19:50:45 (GMT) |
commit | 5f782119c8f368c6ef99a8d4e3b531cbef995cb6 (patch) | |
tree | 2b06cc6002c467c486f9265126c1385d197fd7dc /Source/QtDialog | |
parent | 39f32f12100a7f06f52cd53875b2a5729e9404a6 (diff) | |
download | CMake-5f782119c8f368c6ef99a8d4e3b531cbef995cb6.zip CMake-5f782119c8f368c6ef99a8d4e3b531cbef995cb6.tar.gz CMake-5f782119c8f368c6ef99a8d4e3b531cbef995cb6.tar.bz2 |
cmake-gui: Restore workaround for crash in file dialog
In commit ce9dbceb42 (QtDialog: remove Qt4-only code, 2020-06-02,
v3.19.0-rc1~712^2~1) we removed an event filter that was thought to be
necessary only as a workaround for a bug in Qt. However, that bug was
fixed in Qt 4.5, and the file dialog still crashes as of Qt 5.14 without
the filter. Restore the workaround pending further investigation.
Fixes: #21400
Diffstat (limited to 'Source/QtDialog')
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.cxx | 13 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 4f4b218..22f5be1 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/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 diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 11c6d3e..c5e6dd4 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/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, |