Cocoa: Guard against recursive event delivery

Fix "Recursive repaint" crash.

Add guard to QCococaWindow::setGeometry and QNSView
updateGeometry to prevent processing window system
events during setGeometry.

Task-number: QTBUG-41449
Change-Id: I304fdf134d433cbc50fafd997ecd91e31cb57f4e
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
This commit is contained in:
Morten Johan Sørvig 2014-10-22 00:41:55 +02:00
parent bb31aa853e
commit 7146cbed6e
3 changed files with 8 additions and 1 deletions

View File

@ -268,6 +268,7 @@ public: // for QNSView
bool m_inConstructor;
bool m_inSetVisible;
bool m_inSetGeometry;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
#endif

View File

@ -381,6 +381,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_windowUnderMouse(false)
, m_inConstructor(true)
, m_inSetVisible(false)
, m_inSetGeometry(false)
#ifndef QT_NO_OPENGL
, m_glContext(0)
#endif
@ -470,6 +471,8 @@ QSurfaceFormat QCocoaWindow::format() const
void QCocoaWindow::setGeometry(const QRect &rectIn)
{
QBoolBlocker inSetGeometry(m_inSetGeometry, true);
QRect rect = rectIn;
// This means it is a call from QWindow::setFramePosition() and
// the coordinates include the frame (size is still the contents rectangle).

View File

@ -362,7 +362,10 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
if (!m_platformWindow->m_inConstructor) {
QWindowSystemInterface::handleGeometryChange(m_window, geometry);
m_platformWindow->updateExposedGeometry();
QWindowSystemInterface::flushWindowSystemEvents();
// Guard against processing window system events during QWindow::setGeometry
// calles, which Qt and Qt applications do not excpect.
if (!m_platformWindow->m_inSetGeometry)
QWindowSystemInterface::flushWindowSystemEvents();
}
}