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

Debug information for ~QObject

    XMLWordPrintable

Details

    Description

      I had a hard time today figuring out why Qt 4.4 issues a

      QObject: Do not delete object, 'unnamed'

      during its event handler. In my code. I ended up patching qobject.cpp to get some more information
      on the object. So here is my suggestion. At the end of QObject::~QObject you currently have:

          if (d->inEventHandler) {
              qWarning("QObject: Do not delete object, '%s', during its event handler!",
              objectName().isNull() ? "unnamed" : qPrintable(objectName()));
          }
      

      I would suggest to move this to the beginning of the destructor (because
      here the internals are not yet cleaned up) and add a dumpObjectInfo(); so that this looks like that:

          QObject::~QObject()
          {
              Q_D(QObject);
              if (d->wasDeleted) {
                  #if defined(QT_DEBUG)
                      qWarning("QObject: Double deletion detected");
                  #endif
                  return;
          }
          
          if (d->inEventHandler) {
              qWarning("QObject: Do not delete object, '%s', during its event handler!",
                  objectName().isNull() ? "unnamed" : qPrintable(objectName()));
              this->dumpObjectInfo();
          }
      

      This would make finding the culprit in these cases much easier, because
      you get information on connected signals etc. Of course you should additionally check if debug output is desired.

      Attachments

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

        Activity

          People

            dzyubenk Denis Dzyubenko (Inactive)
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes