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

macOS: NPE in QNSWindow applicationActivationChanged

    XMLWordPrintable

Details

    • macOS
    • 778acfe12 (dev), 7e34539e7 (6.6), 2b4737af3 (tqtc/lts-6.5), c3cd77fe9 (tqtc/lts-6.2)

    Description

      We received a crash report that suggests that platformWindow property for a QCocoaNSWindow was null when the application was activated.

       

      I'm attaching the crash file.

      In qnswindow.mm, when the application becomes active, some code runs to set window display levels:

       

              if ([window conformsToProtocol:@protocol(QNSWindowProtocol)]) {
                  QCocoaWindow *cocoaWindow = static_cast<QCocoaNSWindow *>(window).platformWindow;
                  window.level = notification.name == NSApplicationWillResignActiveNotification ?
                      NSNormalWindowLevel : cocoaWindow->windowLevel(cocoaWindow->window()->flags());
              }

      In this particular case, the code crashed in a way that suggests that the cocoaWindow variable was null. This comes from the platformWindow property of the QCocoaNSWindow.

      I notice that this property is backed by a QPointer, with a note that sometimes the platformWindow is deleted before the os-level window is destroyed. There are also other places in the code that check for nullptr before using the property. So it is acknowledged that it is possible for this property to be null.

      It seems like a simple nullptr check would resolve this issue.

      I have no way of reproducing it. I've tried. It probably requires very particular timing.

      Attachments

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

        Activity

          People

            vestbo Tor Arne Vestbø
            dzedsystems Dyami Caliri
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: