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

Clearing the undo stack of a QTextDocument triggers critical exception

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.12.5
    • 5.11.3, 5.12.0
    • GUI: Text handling
    • None
    • Windows
    • 79e0effead13f60676bb5170fe92615d981827e7

    Description

      When i call QTextDocument::clearUndoRedoStacks(QTextDocument::UndoStack) an index out of bounds exception is triggered by QVector. This i originates from the QTextDocumentPrivate class, in fact in qtextdocument_p.cpp line 1105, there is the following code snippet:

      for (int i = 0; i < undoState; ++i) {
                  QTextUndoCommand c = undoStack.at(undoState);
                  if (c.command & QTextUndoCommand::Custom)
                      delete c.custom;
              }
      

      which seems an obvious mistake. This code is executed only when passing QTextDocument::UndoStack as argument, not with RedoStack or UndoAndRedoStacks.

      Here is the code to replicate the exception

      QTextDocument doc;
      QTextCursor c(&doc);
      c.insertText("lorem ipsum");
      doc.clearUndoRedoStacks(QTextDocument::UndoStack);
      

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            pe_albe Alberto Pellizzon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes