Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix crash on MacOS
  • Loading branch information
PeterPetrik authored and nyalldawson committed Feb 18, 2021
1 parent edb7b52 commit 6768520
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/gui/qgsfocuskeeper.cpp
Expand Up @@ -21,12 +21,14 @@

QgsFocusKeeper::QgsFocusKeeper(): mWidgetToKeepFocused( QApplication::focusWidget() )
{
mWidgetToKeepFocused->installEventFilter( this );
if ( mWidgetToKeepFocused )
mWidgetToKeepFocused->installEventFilter( this );
}

QgsFocusKeeper::~QgsFocusKeeper()
{
mWidgetToKeepFocused->removeEventFilter( this );
if ( mWidgetToKeepFocused )
mWidgetToKeepFocused->removeEventFilter( this );
}

bool QgsFocusKeeper::eventFilter( QObject *obj, QEvent *event )
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsfocuskeeper.h
Expand Up @@ -21,6 +21,7 @@
#define SIP_NO_FILE

#include <QObject>
#include <QPointer>

class QWidget;

Expand All @@ -35,7 +36,7 @@ class GUI_EXPORT QgsFocusKeeper : public QObject
{
Q_OBJECT

QWidget *mWidgetToKeepFocused = nullptr;
QPointer<QWidget> mWidgetToKeepFocused;

public:
QgsFocusKeeper();
Expand Down

0 comments on commit 6768520

Please sign in to comment.