Cocoa: Remove the NSWindow -> QCococaWindow hash.
Cast the NSWindow to a QNSWindow instead. Now there is no way we can fail to maintain the hash properly. Change-Id: I5fd03b6fad964a61fadb3460b7063fd43ff25c79 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
7ba0eb5a0d
commit
1ac0f953ba
@ -139,8 +139,6 @@ public:
|
||||
void setToolbar(QWindow *window, NSToolbar *toolbar);
|
||||
NSToolbar *toolbar(QWindow *window) const;
|
||||
void clearToolbars();
|
||||
void setWindow(NSWindow* nsWindow, QCocoaWindow *window);
|
||||
QCocoaWindow *window(NSWindow *window);
|
||||
private:
|
||||
static QCocoaIntegration *mInstance;
|
||||
|
||||
@ -159,7 +157,6 @@ private:
|
||||
QScopedPointer<QCocoaKeyMapper> mKeyboardMapper;
|
||||
|
||||
QHash<QWindow *, NSToolbar *> mToolbars;
|
||||
QHash<NSWindow *, QCocoaWindow*> mWindows;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -159,9 +159,12 @@ qreal QCocoaScreen::devicePixelRatio() const
|
||||
QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
|
||||
{
|
||||
// Get a z-ordered list of windows. Iterate through it until
|
||||
// we find a window which contains the point.
|
||||
// we find a (Qt) window which contains the point.
|
||||
for (NSWindow *nsWindow in [NSApp orderedWindows]) {
|
||||
QCocoaWindow *cocoaWindow = QCocoaIntegration::instance()->window(nsWindow);
|
||||
if (![nsWindow isKindOfClass:[QNSWindow class]])
|
||||
continue;
|
||||
QNSWindow *qnsWindow = static_cast<QNSWindow *>(nsWindow);
|
||||
QCocoaWindow *cocoaWindow = qnsWindow.helper.platformWindow;
|
||||
if (!cocoaWindow)
|
||||
continue;
|
||||
QWindow *window = cocoaWindow->window();
|
||||
@ -518,16 +521,6 @@ NSToolbar *QCocoaIntegration::toolbar(QWindow *window) const
|
||||
return mToolbars.value(window);
|
||||
}
|
||||
|
||||
void QCocoaIntegration::setWindow(NSWindow* nsWindow, QCocoaWindow *window)
|
||||
{
|
||||
mWindows.insert(nsWindow, window);
|
||||
}
|
||||
|
||||
QCocoaWindow *QCocoaIntegration::window(NSWindow *window)
|
||||
{
|
||||
return mWindows.value(window);
|
||||
}
|
||||
|
||||
void QCocoaIntegration::clearToolbars()
|
||||
{
|
||||
QHash<QWindow *, NSToolbar *>::const_iterator it = mToolbars.constBegin();
|
||||
|
@ -262,8 +262,6 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
{
|
||||
[self close];
|
||||
|
||||
QCocoaIntegration::instance()->setWindow(self, 0);
|
||||
|
||||
if (self.helper.grabbingMouse) {
|
||||
self.helper.releaseOnMouseUp = YES;
|
||||
} else {
|
||||
@ -330,7 +328,6 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
{
|
||||
[self.helper detachFromPlatformWindow];
|
||||
[self close];
|
||||
QCocoaIntegration::instance()->setWindow(self, 0);
|
||||
[self release];
|
||||
}
|
||||
|
||||
@ -1414,8 +1411,6 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
|
||||
|
||||
applyContentBorderThickness(createdWindow);
|
||||
|
||||
QCocoaIntegration::instance()->setWindow(createdWindow, this);
|
||||
|
||||
return createdWindow;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user