diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-02-18 12:00:27 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-03-04 10:37:25 +0000 |
commit | 7d2c7ca8fad2d8177599ba3a4851c48d3baf5772 (patch) | |
tree | f29457ec891fb028cc113e7d0eef35bfdb17eb2f /src/gui/text/qfontengine_ft_p.h | |
parent | 5cd455dca309d0d031057ab40ff607d144683d43 (diff) |
QFontEngine: use RAII for font_, face_ members
Wrap the pairs of (void *ptr, void (*dtor)(void*)) in essentially
a std::unique_ptr. This simplifies code and provides the correct
implicit destruction, so we can drop the explicit glyph-cache
clear()ing in ~QFontEngine(), leaving that job to ~QLinkedList.
A subsequent change will turn the QLinkedList into a C array, the
clearing of which would otherwise cause excessive code bloat.
Since we can't use std::unique_ptr, yet, provide a hand-rolled
replacement for now, marking it for replacement with unique_ptr
once we can use it. Make that a local type instead of providing
a Qt-wide unique_ptr so we don't accidentally lock ourselves into
a half-baked std clone we can't get rid of anymore.
To prepare unique_ptr use with the same type-erased deleter
(function pointer) as now, replace a nullptr destroy_function
with a no-op function, so ~unique_ptr doesn't crash when we
port to it later.
Because QFreetypeFace contains the same construct and shares
payloads with QFontEngine, use the Holder there, too.
Even saves 150b in text size on optimized GCC 5.3 AMD64 builds.
Change-Id: I5ca11a3e6e1ff9e06199124403d96e1b280f3eb2
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/gui/text/qfontengine_ft_p.h')
-rw-r--r-- | src/gui/text/qfontengine_ft_p.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 1886fc67ba..f9b37ff039 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -121,8 +121,7 @@ private: QMutex _lock; QByteArray fontData; - void *hbFace; - qt_destroy_func_t hbFace_destroy_func; + QFontEngine::Holder hbFace; }; // If this is exported this breaks compilation of the windows |