Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Crash within Qt Code using drag and drop (Qt BUG?)

Crash within Qt Code using drag and drop (Qt BUG?)

Scheduled Pinned Locked Moved General and Desktop
13 Posts 2 Posters 7.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    robby876
    wrote on last edited by
    #4

    Since I have only been debugging with the Qt source today, I have seen it happens in more than one location in the function above.

    It seems to me to be the data pointer becomes invalid, if I could find out what this is then I would be able to trace it back, however, it is obtained from

    QThreadData * volatile * pdata = &receiver->d_func()->threadData;

    and d_func() doesn't seem accessible from the source I have.

    @

    }
    
    QThreadData * volatile * pdata = &receiver->d_func()->threadData;
    QThreadData *data = *pdata;
    if (!data) {
        // posting during destruction? just delete the event to prevent a leak
        delete event;
        return;
    }
    
    // lock the post event mutex
    data->postEventList.mutex.lock();
    
    // if object has moved to another thread, follow it
    while (data != *pdata) {
        data->postEventList.mutex.unlock();  <============= CRASH CAN ALSO HAPPEN HERE
    
        data = *pdata;
        if (!data) {
            // posting during destruction? just delete the event to prevent a leak
            delete event;
            return;
    

    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      First thing that comes to my mind:
      Do you use the delete operator or deleteLater function from QObject ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • R Offline
        R Offline
        robby876
        wrote on last edited by
        #6

        Yes, in a number of places

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #7

          Sorry but, yes to what ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            robby876
            wrote on last edited by
            #8

            I use both the delete and deletelater functions, on widgets and occasionally on the drag object (before exec() ) is called, it will not be called if it is deleted.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              I would rather avoid using delete on widgets, unless you're really sure about the state of that widget (parenting etc...)

              And since the drag object is a child of your current widget, it should also be automatically deleted.

              And last thing, i would set _widget to 0 in the destructor of your custom QMimeData (or use something like a QPointer)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • R Offline
                R Offline
                robby876
                wrote on last edited by
                #10

                I need to delete the widget, if it is not dropped as it is created for being dragged into the container, if the drag fails it should be deleted, otherwise it will sit in memory until the application is closed.

                The code that calls the deletion of the drag does not get called, it is only for if the creation of the widget fails, which does not happen.

                I will set the widget to 0 in the destruction of the mime data, and see if this helps.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  Why do you create it there then ? Wouldn't it be safer to serialize your widget properties (i.e. in xml) and then use that to create the widget in the drop function ? So if no drop occurs, no need to handle that widget.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    robby876
                    wrote on last edited by
                    #12

                    Widgets can also be moved, from one place to another. These widgets are connected up to the backend via a (thread safe) shared control object and all setting show on the GUI match up. Due to this, it is far easier to create the widget and then destroy it if required.

                    I really don't think the issue is with deleting the widgets. As looking into the code, the object getting deleted is the QXdndDropTransaction object. This is handled by Qt itself.

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      robby876
                      wrote on last edited by
                      #13

                      Done the changes to making the widget = 0 after destruction of the mime data, I've also removed a few deletes (temp change)... To no avail... I'm beginning to wonder if this is a bug in Qt.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved