summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qfontengine_p.h')
-rw-r--r--src/gui/text/qfontengine_p.h44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index f97f91da50..1ef3a360d4 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -275,10 +275,45 @@ public:
QAtomicInt ref;
QFontDef fontDef;
- mutable void *font_;
- mutable qt_destroy_func_t font_destroy_func;
- mutable void *face_;
- mutable qt_destroy_func_t face_destroy_func;
+ class Holder { // replace by std::unique_ptr once available
+ void *ptr;
+ qt_destroy_func_t destroy_func;
+ public:
+ Holder() : ptr(nullptr), destroy_func(nullptr) {}
+ explicit Holder(void *p, qt_destroy_func_t d) : ptr(p), destroy_func(d) {}
+ ~Holder() { if (ptr && destroy_func) destroy_func(ptr); }
+ Holder(Holder &&other) Q_DECL_NOTHROW
+ : ptr(other.ptr),
+ destroy_func(other.destroy_func)
+ {
+ other.ptr = nullptr;
+ other.destroy_func = nullptr;
+ }
+ Holder &operator=(Holder &&other) Q_DECL_NOTHROW
+ { swap(other); return *this; }
+
+ void swap(Holder &other) Q_DECL_NOTHROW
+ {
+ qSwap(ptr, other.ptr);
+ qSwap(destroy_func, other.destroy_func);
+ }
+
+ void *get() const Q_DECL_NOTHROW { return ptr; }
+ void *release() Q_DECL_NOTHROW {
+ void *result = ptr;
+ ptr = nullptr;
+ destroy_func = nullptr;
+ return result;
+ }
+ void reset() Q_DECL_NOTHROW { Holder().swap(*this); }
+ qt_destroy_func_t get_deleter() const Q_DECL_NOTHROW { return destroy_func; }
+
+ bool operator!() const Q_DECL_NOTHROW { return !ptr; }
+ };
+
+ mutable Holder font_; // \ NOTE: Declared before m_glyphCaches, so font_, face_
+ mutable Holder face_; // / are destroyed _after_ m_glyphCaches is destroyed.
+
struct FaceData {
void *user_data;
qt_get_font_table_func_t get_font_table;
@@ -334,6 +369,7 @@ private:
mutable qreal m_minRightBearing;
};
+Q_DECLARE_TYPEINFO(QFontEngine::KernPair, Q_PRIMITIVE_TYPE);
Q_DECLARE_OPERATORS_FOR_FLAGS(QFontEngine::ShaperFlags)