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

Disappearing lines when using a syntax highlighter

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 5.15.1
    • 4.7.2, 4.7.3, 5.12.0, 5.12.8, 6.7.0
    • GUI: Text handling
    • None
    • Ubuntu 11.04, Windows
    • All
    • 09ee4282e5eedf5b44245e8b28b223339f87ddfa (qt/qtbase/5.15)

    Description

      When I use a QSyntaxHighlighter-derived class and call highlighter.rehighlight() in the initialization phase of the program/window, several lines simply vanish in the initial display. One has to resize the window horizontally (presumably to cause a relayout of the text) to show those lines.

      This problem was originally reported for the TeXworks project (http://code.google.com/p/texworks/issues/detail?id=469, http://code.google.com/p/texworks/issues/detail?id=497, http://code.google.com/p/texworks/issues/detail?id=505), but I've managed to distill a (minimal) example (see attachment).

      The exact manifestation of the problem seems to depend on the Qt version used. So far, I've tested the following ones (the missing lines are for the attached minimal example):

      • gcc 4.5.2
        • Qt 4.6.3 (debug) works
        • Qt 4.7.2 (debug) fails, missing lines: 144—147, 154—157, 160—161, 169—181
      • gcc 4.6.0
        • Qt 4.7.3 fails, missing lines: 155-157, 160-161, 169-181

      I'm not sure if this is also system-dependent?

      A few things to note:

      • this is independent of the window's initial size, but manual horizontal resize works around the problem
      • moving rehighlight() in front of show() apparently solves the problem as well (though this might not be possible in real-life if rehighlight is tied to signals and/or other parts of the code, e.g., for document parsing)
      • which lines are missing depends on the highlighting definition (changing ".*$" to ".+$" made lines 137—143 disappear with Qt 4.7.2)
      • the cursor disappears when moving to hidden lines with the arrow keys (the real app, TeXworks, crashes, presumably due to the "highlight current line" feature which uses the code from http://doc.qt.nokia.com/latest/widgets-codeeditor.html)

      Some additional debugging suggests that the text is properly split into QTextBlocks, but that those are not (all) laid out properly into QTextLines.

      I'd be grateful for any insight and would be happy to provide any additional information you might need.

      Attachments

        1. Screenshot_with_qt_6_7_0.png
          Screenshot_with_qt_6_7_0.png
          37 kB
        2. qtbug20354_qt6.zip
          1.62 MB
        3. problem.txt
          8 kB
        4. main-segfault.cpp
          2 kB
        5. main.cpp
          1 kB
        6. 0001-Fix-invalid-text-layout-data-when-a-full-layout-run-.patch
          3 kB
        For Gerrit Dashboard: QTBUG-20354
        # Subject Branch Project Status CR V

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            st.loeffler Stefan Löffler
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated: