summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.h
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-19 11:04:19 +0200
committerLiang Qi <liang.qi@qt.io>2016-05-19 12:55:27 +0200
commit818014b449ef996099b4795a82f09651cf1c0129 (patch)
tree02f991007097fa368491a81eebbabe4cc162a0e0 /src/plugins/platforms/cocoa/qcocoawindow.h
parente6cc1d788dddda2998a9f941664ede928ce1e212 (diff)
parent640441882d20f86db05ab5fd1141abe39a0bd409 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: configure src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp src/network/access/qnetworkaccessmanager.cpp src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h src/widgets/widgets/qlineedit_p.cpp src/widgets/widgets/qlineedit_p.h src/winmain/winmain.pro tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp tools/configure/configureapp.cpp Change-Id: Ib9997b0d0f91946e4081d36c0c6b696c5c983b2a
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.h')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 4d5f5d74f2..d9e94735ac 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -44,6 +44,7 @@
#include <qpa/qplatformwindow.h>
#include <QRect>
+#include <QPointer>
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
@@ -53,6 +54,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
@@ -69,14 +96,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;
@@ -260,7 +286,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
@@ -323,9 +349,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;
};