]> git.lyx.org Git - features.git/commit
Do not use a static variable as QTextLayout cache
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 11 Dec 2015 15:33:34 +0000 (16:33 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 16 Dec 2015 09:34:43 +0000 (10:34 +0100)
commit91b385166de84677197f326702f0e95a5d649091
treee5788237a16ac302a147cfdc78f80b6782d385fd
parentffe376a6478dccab6337eafa1f159377e9855938
Do not use a static variable as QTextLayout cache

It is a bad idea to have a QObject variable that oulives the main QApplication object. See for example:
https://www.ics.com/designpatterns/book/globals.html

Here the QTextLayout object was static to the anonymous namespace getTextLayout function, and got destroyed after the freetype renderer had been disposed of by QApplication.

This causes segmentation faults when quitting LyX on some systems.

This patch moves the cache together with other GuiFontMetrics caches. It means that one will have one such QTextLayout per font type, but this will not change much.
src/frontends/qt4/GuiFontMetrics.cpp
src/frontends/qt4/GuiFontMetrics.h