diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.h')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index e60ca196ac..9fcb221d37 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -38,6 +38,7 @@ #include <qpa/qplatformwindow.h> #include <QRect> +#include <QPointer> #ifndef QT_NO_OPENGL #include "qcocoaglcontext.h" @@ -47,6 +48,32 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow) +QT_BEGIN_NAMESPACE + +class QCocoaWindowPointer +{ +public: + void assign(QCocoaWindow *w); + void clear(); + + QCocoaWindow *data() const + { return watcher.isNull() ? Q_NULLPTR : window; } + bool isNull() const + { return watcher.isNull(); } + operator QCocoaWindow*() const + { return data(); } + QCocoaWindow *operator->() const + { return data(); } + QCocoaWindow &operator*() const + { return *data(); } + +private: + QPointer<QObject> watcher; + QCocoaWindow *window; +}; + +QT_END_NAMESPACE + @class QT_MANGLE_NAMESPACE(QNSWindowHelper); @protocol QNSWindowProtocol @@ -63,14 +90,13 @@ typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow; @interface QT_MANGLE_NAMESPACE(QNSWindowHelper) : NSObject { QCocoaNSWindow *_window; - QCocoaWindow *_platformWindow; + QCocoaWindowPointer _platformWindow; BOOL _grabbingMouse; BOOL _releaseOnMouseUp; - QPointer<QObject> _watcher; } @property (nonatomic, readonly) QCocoaNSWindow *window; -@property (nonatomic, readonly) QCocoaWindow *platformWindow; +@property (nonatomic, readonly) QCocoaWindowPointer platformWindow; @property (nonatomic) BOOL grabbingMouse; @property (nonatomic) BOOL releaseOnMouseUp; @@ -254,7 +280,7 @@ public: // for QNSView NSView *m_contentView; QNSView *m_qtView; QCocoaNSWindow *m_nsWindow; - QCocoaWindow *m_forwardWindow; + QCocoaWindowPointer m_forwardWindow; // TODO merge to one variable if possible bool m_contentViewIsEmbedded; // true if the m_contentView is actually embedded in a "foreign" NSView hiearchy @@ -317,9 +343,8 @@ public: // for QNSView QHash<quintptr, BorderRange> m_contentBorderAreas; // identifer -> uppper/lower QHash<quintptr, bool> m_enabledContentBorderAreas; // identifer -> enabled state (true/false) - // This object is tracked by a 'watcher' - // object in a window helper, preventing use of dangling - // pointers. + // This object is tracked by QCocoaWindowPointer, + // preventing the use of dangling pointers. QObject sentinel; }; |