Skip to content

Commit

Permalink
Qt 5.12.5+: fixed an issue wit our property editor that would crash O…
Browse files Browse the repository at this point in the history
…penCOR (#2211).
  • Loading branch information
agarny committed Nov 14, 2019
1 parent 1a01626 commit 652e833
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/plugins/miscellaneous/Core/src/propertyeditorwidget.cpp
Expand Up @@ -45,6 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QStandardItem>
#include <QStyle>
#include <QStyleOptionViewItem>
#include <QTimer>
#include <QVariant>

//==============================================================================
Expand Down Expand Up @@ -2031,6 +2032,15 @@ void PropertyEditorWidget::checkCheckState(QStandardItem *pItem)

//==============================================================================

void PropertyEditorWidget::updateFocusProxy()
{
// Set our property's editor as our focus proxy

setFocusProxy(mPropertyEditor);
}

//==============================================================================

void PropertyEditorWidget::editorOpened(QWidget *pEditor)
{
// Keep track of some information about the property
Expand Down Expand Up @@ -2058,14 +2068,17 @@ void PropertyEditorWidget::editorOpened(QWidget *pEditor)

// Next, we need to use the property's editor as our focus proxy and make
// sure that it immediately gets the focus
// Note: if we were not to immediately give the focus to our editor, then
// the central widget would give the focus to the previously focused
// widget (see CentralWidget::updateGui()), which is clearly not what
// we want...

setFocusProxy(pEditor);
// Note #1: if we were not to immediately give the focus to our editor, then
// the central widget would give the focus to the previously
// focused widget (see CentralWidget::updateGui()), which is
// clearly not what we want...
// Note #2: starting with Qt 5.12.5, we can't immediately set the property's
// editor as our focus proxy (!?). This will indeed crash OpenCOR!
// So, instead, we set it through a single shot...

pEditor->setFocus();

QTimer::singleShot(0, this, &PropertyEditorWidget::updateFocusProxy);
}

//==============================================================================
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/miscellaneous/Core/src/propertyeditorwidget.h
Expand Up @@ -472,6 +472,8 @@ private slots:

void checkCheckState(QStandardItem *pItem);

void updateFocusProxy();

void editorOpened(QWidget *pEditor);
void editorClosed();

Expand Down

0 comments on commit 652e833

Please sign in to comment.