CoreText: Use QCFType to track CoreFoundation member variables
The operator T() function of QAppleRefCounted should be const so that the underlying type can be accessed from const member functions just like the naked underlying type could. Change-Id: I0819c5795d28442a6ff4db2732e211b183574f9f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
61a94d2d04
commit
d3ec5a2b09
@ -89,7 +89,7 @@ public:
|
||||
QAppleRefCounted(QAppleRefCounted &&other) : value(other.value) { other.value = T(); }
|
||||
QAppleRefCounted(const QAppleRefCounted &other) : value(other.value) { if (value) RetainFunction(value); }
|
||||
~QAppleRefCounted() { if (value) ReleaseFunction(value); }
|
||||
operator T() { return value; }
|
||||
operator T() const { return value; }
|
||||
void swap(QAppleRefCounted &other) Q_DECL_NOEXCEPT_EXPR(noexcept(qSwap(value, other.value)))
|
||||
{ qSwap(value, other.value); }
|
||||
QAppleRefCounted &operator=(const QAppleRefCounted &other)
|
||||
|
@ -192,19 +192,16 @@ QCoreTextFontEngine *QCoreTextFontEngine::create(const QByteArray &fontData, qre
|
||||
QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def)
|
||||
: QCoreTextFontEngine(def)
|
||||
{
|
||||
ctfont = font;
|
||||
CFRetain(ctfont);
|
||||
cgFont = CTFontCopyGraphicsFont(font, NULL);
|
||||
ctfont = QCFType<CTFontRef>::constructFromGet(font);
|
||||
cgFont = CTFontCopyGraphicsFont(font, nullptr);
|
||||
init();
|
||||
}
|
||||
|
||||
QCoreTextFontEngine::QCoreTextFontEngine(CGFontRef font, const QFontDef &def)
|
||||
: QCoreTextFontEngine(def)
|
||||
{
|
||||
cgFont = font;
|
||||
// Keep reference count balanced
|
||||
CFRetain(cgFont);
|
||||
ctfont = CTFontCreateWithGraphicsFont(font, fontDef.pixelSize, &transform, NULL);
|
||||
cgFont = QCFType<CGFontRef>::constructFromGet(font);
|
||||
ctfont = CTFontCreateWithGraphicsFont(font, fontDef.pixelSize, &transform, nullptr);
|
||||
init();
|
||||
}
|
||||
|
||||
@ -217,14 +214,12 @@ QCoreTextFontEngine::QCoreTextFontEngine(const QFontDef &def)
|
||||
|
||||
QCoreTextFontEngine::~QCoreTextFontEngine()
|
||||
{
|
||||
CFRelease(cgFont);
|
||||
CFRelease(ctfont);
|
||||
}
|
||||
|
||||
void QCoreTextFontEngine::init()
|
||||
{
|
||||
Q_ASSERT(ctfont != NULL);
|
||||
Q_ASSERT(cgFont != NULL);
|
||||
Q_ASSERT(ctfont);
|
||||
Q_ASSERT(cgFont);
|
||||
|
||||
face_id.index = 0;
|
||||
QCFString name = CTFontCopyName(ctfont, kCTFontUniqueNameKey);
|
||||
@ -856,7 +851,7 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
|
||||
|
||||
Qt::HANDLE QCoreTextFontEngine::handle() const
|
||||
{
|
||||
return (Qt::HANDLE)ctfont;
|
||||
return (Qt::HANDLE)(static_cast<CTFontRef>(ctfont));
|
||||
}
|
||||
|
||||
bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) const
|
||||
|
@ -131,8 +131,8 @@ protected:
|
||||
QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, bool colorful, const QTransform &m);
|
||||
void loadAdvancesForGlyphs(QVarLengthArray<CGGlyph> &cgGlyphs, QGlyphLayout *glyphs) const;
|
||||
|
||||
CTFontRef ctfont;
|
||||
CGFontRef cgFont;
|
||||
QCFType<CTFontRef> ctfont;
|
||||
QCFType<CGFontRef> cgFont;
|
||||
int synthesisFlags;
|
||||
CGAffineTransform transform;
|
||||
QFixed avgCharWidth;
|
||||
|
Loading…
Reference in New Issue
Block a user