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

QPlainTextEdit::createStandardContextMenu is wrong about ownership

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.6.1, 6.6.2
    • Quick: Widget
    • None

    Description

      The Documentation of QPlainTextEdit::createStandardContextMenu(const QPoint &position) states that: "The popup menu's ownership is transferred to the caller." This is not 100% correct, as inside the implementation "this" is set as the parent of the menu in QPlainTextEdit::createStandardContextMenu() and in QPlainTextEdit::createStandardContextMenu(QPoint...).

      If a user tries to write code like this:

      QMenu *menu = plainTextControl->createStandardContextMenu();
      menu->exec();
      delete menu;

      a crash can happen when calling delete menu; if the plainTextControl is already destroyed during the exec.

      Also while the documentation of the function with argument states the incorrect, the documentation of the function without the argument does not. They should both state it or none of them.

      Attachments

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

        Activity

          People

            tvete Paul Olav Tvete
            madwinter Marcus Tillmanns
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes