Commit 7d2c7ca8 authored by Marc Mutz's avatar Marc Mutz
Browse files

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: default avatarKonstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: default avatarLars Knoll <lars.knoll@theqtcompany.com>
Showing with 59 additions and 50 deletions
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment