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

Crash when QLabel's buddy is deleted but not unset as buddy

    XMLWordPrintable

Details

    • c082d84d5d7fdbfb64de18f06a8ddbc77f2e6de4 (5.11) 2b4078cbb0d6bde9a681d1b3120aa586ab6c162d (5.9.5)

    Description

      If a label has a buddy and the buddy is deleted there will be a crash in QLabel::event() when the buddy is dereferenced.

      Fix is in progress at https://codereview.qt-project.org/#/c/222041/

      Example:

      {noformat}

      #include <QtWidgets>

      int main(int a, char **b)
      {
          QApplication app(a, b);

          QWidget w;
          w.resize(500, 500);
          auto lay = new QVBoxLayout(&w);
          auto le = new QLineEdit();
          auto la = new QLabel("&Test");
          la->setBuddy(le);
          lay->addWidget(la);
          lay->addWidget(le);

          auto but = new QPushButton("Delete buddy");
          lay->addWidget(but);
          QObject::connect(but, &QPushButton::clicked, le, [le] {
              delete le;
              qDebug() << "Deleted line edit. Now use the shortcut alt+t.";
          });

          w.show();

          return app.exec();
      }

      {noformat}

      Attachments

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

        Activity

          People

            iamsergio Sergio Martins
            iamsergio Sergio Martins
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes