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

Crash during drag n drop operation when using two Qt versions in same process on macOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P1: Critical
    • None
    • 6.0.1
    • Image formats
    • None
    • macOS

    Description

      I'm not sure if this is a bug in Qt or if objective-C is to blame for it, but the problem can be addressed in Qt, hence this log. Unfortunately I can't provide a test program to reproduce the issue, but I think I've pinpointed the problem close enough to give a clear idea of what's going on.

      The software I'm working on uses Qt (obviously), linked dynamically, but also uses a dynamic library (that also uses Qt) from another company. That library is provided as a binary linked statically to their Qt version, and the only symbols that library exports are related to the functionality the dylib provides (nothing Qt related).

      We recently switched to Qt6 in order to have a version that runs natively on Apple Silicon and that company provided us with an updated version of the library for the same reason (I'm assuming there's a Qt 5.15 or a Qt6 in there but I didn't ask them).

       

      The problem I'm now running into is that whenever I start a drag operation my application will abort in debug (because an assert is triggered) and not display the drag image in release.

       

      After quite some debugging I tracked down the source of the problem to the following code in QCoreGraphics:

       

      @interface NSImage (QtExtras)
      + (instancetype)imageFromQImage:(const QT_PREPEND_NAMESPACE(QImage) &)image;
      + (instancetype)imageFromQIcon:(const QT_PREPEND_NAMESPACE(QIcon) &)icon;
      + (instancetype)imageFromQIcon:(const QT_PREPEND_NAMESPACE(QIcon) &)icon withSize:(int)size;
      @end
      

      I have the impression that the QtExtras category of the two Qt's are somehow interfering with each other. Having no idea on how that category system works in Objective C in the somewhat unusual setup of the application, I can't tell if this is a Qt or an Objective-C problem, but I do know that replacing that category extension of NSImage with free functions in the Qt namespace solves my problem (update to header shown below).

       

       

      Q_GUI_EXPORT NSImage * createNSImageFromQImage( QImage const & image);
      Q_GUI_EXPORT NSImage * createNSImageFromQIcon( QIcon const & image );
      Q_GUI_EXPORT NSImage * createNSImageFromQIconWithSize( QIcon const & image, int size);
      

       

      A similar crash affects custom mouse cursors and QWidget::setWindowIcon amongst others.

        

      I'm now wondering if there was a particular reason to switch to the category mechanism (apart from the apparent elegance) or if this can/will be changed to free functions in a future version?

       

      I'm also slightly worried other Qt code that relies on category extensions may misbehave, although no symptoms have manifested just yet...

      Attachments

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

        Activity

          People

            vestbo Tor Arne Vestbø
            gvanvoor Gregory Van Vooren
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes