Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85915

macOS crash when opening several times QComboBox drop downs after moving application windows from one screen to another



    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.12.7, 5.12.8, 5.12.9
    • Fix Version/s: 5.12.10, 5.15.2
    • Component/s: QPA
    • Labels:
    • Environment:
      macOS 10.14.6 Xcode 10.3, Qt Creator 4.12.2
      two screens
    • Platform/s:
    • Commits:
      abb985a4032a337581aa885e1ac547287244b695 (qt/qtbase/dev) caa68b9c538aa30ec6fc3feed2847fbe53d904b6 (qt/qtbase/5.12)


      Since Qt5.12.7 I can reproduce a crash on macOS 10.14 or 10.15 when having an application with one or more QComboBox objects and after the application is started, move the application from one screen to another screen and then just click to open the drop down and click to close the drop down (you do not need to select anything in the drop down). Perform this open/close of the drop down of the QComboBox objects a few times and the application is crashing.

      The crash happens in QCocoaBackingStore::colorSpace() in the cocoa platform plugin called from the QCALayerBackingStore::backingPropertiesChanged().
      This code part was introduced with the fix for https://bugreports.qt.io/browse/QTBUG-80844

      I can reproduce the crash using Xcode as debugger.
      When using QtCreator as debugger then the crash does not occur (not sure what the QtCreator debugger or starting of the application through the debugger is changing).
      It is reproducible if building with QtCreator and then starting the application e.g. from the macOS Terminal.

      I have attached a simple test program which has a main window and 3 QComboBox objects, see attachment:"testComboBoxOpenCrash.zip"

      I have attached a screen shot when using Xcode as debugger, see attachment:"CrashTestOpenComboBox_Debugger.png"

      It can be seen that the QComboBox::showPopup() is called which then calls the methods

      • QWidget::create
      • QWidgetPrivate::create
      • QWindow::create
      • QWindowPrivate::create
      • QCocoaWindow::initialize
      • QCocoaWindow::recreateWindowIfNeeded
      • QCocoaWindow::createNSWindow
      • QNSPanel initWithContentRect:styleMask:backing:defer:screen:
      • NSWindow initWithContentRect:styleMask:backing:defer:screen:

      Now an NSObserver is called and this is the one which was registered in the constructor of QCALayerBackingStore
      The callback QCALayerBackingStore::backingPropertiesChanged() is called which want to update the color space for the existing buffers.

      void QCALayerBackingStore::backingPropertiesChanged()
          qCDebug(lcQpaBackingStore) << "Updating color space of existing buffers";
          for (auto &buffer : m_buffers) {
              if (buffer)

      There will be called the colorSpace() in the QCocoaBackingStore

      QCFType<CGColorSpaceRef> QCocoaBackingStore::colorSpace() const
          NSView *view = static_cast<QCocoaWindow *>(window()->handle())->view();
          return QCFType<CGColorSpaceRef>::constructFromGet(view.window.colorSpace.CGColorSpace);


      static_cast<QCocoaWindow *>(window()->handle())

      seems to return a nullptr and hence the further access to view()

      static_cast<QCocoaWindow *>(window()->handle())->view()

      results in a bad access exception.

      Last method in the call stack is QCocoaWindow::view() and the debugger shows this = NULL see attached screen shot "QCocoaWindow_view_this_NULL.png" which confirms that

      static_cast<QCocoaWindow *>(window()->handle())

      resulted in NULL.


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            vestbo Tor Arne Vestbø
            andreasr Andreas Renz
            0 Vote for this issue
            4 Start watching this issue