-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dock: Destory display at SurfaceAboutToBeDestroyed
When the dock is floating, SurfaceAboutToBeDestroyed event arrives earlier than ~ScopeWidget(). Let's delete at the event. On the other hand, if it's docked, ~ScopeWidget() arrives earlier than SurfaceAboutToBeDestroyed. I need to remove the event filter not to access the released object from the surface event filter.
- Loading branch information
Showing
3 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
#include <QObject> | ||
|
||
template<typename QTDisplay_class> class SurfaceEventFilter : public QObject { | ||
QTDisplay_class *w; | ||
|
||
public: | ||
SurfaceEventFilter(QTDisplay_class *w_) : w(w_) {} | ||
|
||
protected: | ||
bool eventFilter(QObject *obj, QEvent *event) override | ||
{ | ||
bool result = QObject::eventFilter(obj, event); | ||
QPlatformSurfaceEvent *surfaceEvent; | ||
|
||
switch (event->type()) { | ||
case QEvent::PlatformSurface: | ||
surfaceEvent = static_cast<QPlatformSurfaceEvent *>(event); | ||
|
||
switch (surfaceEvent->surfaceEventType()) { | ||
case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed: | ||
w->DestroyDisplay(); | ||
break; | ||
default: | ||
break; | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters