diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 6aa0c0182f2..6ea6714649f 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -357,6 +357,14 @@ QCALayerBackingStore::QCALayerBackingStore(QWindow *window) NSView *view = static_cast(window->handle())->view(); m_backingPropertiesObserver = QMacNotificationObserver(view.window, NSWindowDidChangeBackingPropertiesNotification, [this]() { + if (!this->window()->handle()) { + // The platform window has been destroyed, but the backingstore + // is still alive, as that's tied to a QWindow. The original + // NSWindow we were observing is also likely gone. FIXME: + // We should listen for surface events from the QWindow and + // remove and re-attach our observer based on those. + return; + } qCDebug(lcQpaBackingStore) << "Backing properties for" << this->window() << "did change"; backingPropertiesChanged();