[texworks] [Qt-interest] Disappearing lines when using a syntax highlighter

Stefan Löffler st.loeffler at gmail.com
Mon Jul 11 07:44:40 CEST 2011


Hi,

I'm a developer of the TeX editor project TeXworks that is based on the
Qt framework. About half a year ago, the problem of the disappearing
lines has been reported [1], but now I finally managed to reproduce it
in a minimal example (source code and test file attached).

Here's the problem: when I use a QSyntaxHighlighter-derived class and
call highlighter.rehighlight() in the initialization, 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 seems to depend on the Qt version used. So far, I've tested the
following ones:
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: 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 solve 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)
- the missing lines depend 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 using 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. But that internal layout code is fairly complex...

Does anyone have any hint as to where this issue comes form or how to
solve this?

Thanks in advance,
Stefan

[1] 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 1356 bytes
Desc: not available
URL: <http://tug.org/pipermail/texworks/attachments/20110711/8858d5e3/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: problem.txt
URL: <http://tug.org/pipermail/texworks/attachments/20110711/8858d5e3/attachment.txt>


More information about the texworks mailing list