Fix hb_face leaking in QFontEngineFT

Since HarfBuzz-old's HB_Face doesn't support ref-counting,
it is impossible to keep the same behavior as for NG's ref-counted hb_face
when we're going to reparent the data of unknown type in QFontEngineFT.

We should either not release the object returned by harfbuzzFace(),
or introduce ref-counting for HB-old's HB_Face. Stop referencing HB-NG's
objects on access for now and thus avoid a need to release them manually.

Task-number: QTBUG-42674
Change-Id: Ia21e7ba9c17185796b0dd98c2c27d02566f2a701
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
Konstantin Ritt 2014-11-14 14:15:04 +04:00 committed by Jani Heikkinen
parent f44eb5c57f
commit 0600f7d629
3 changed files with 2 additions and 8 deletions

View File

@ -373,8 +373,6 @@ bool QFontEngine::supportsScript(QChar::Script script) const
if (!ret && script_tag_2 != HB_OT_TAG_DEFAULT_SCRIPT)
ret = hb_ot_layout_table_find_script(face, HB_OT_TAG_GSUB, HB_OT_TAG_DEFAULT_SCRIPT, &script_index);
}
hb_face_destroy(face);
}
return ret;
}

View File

@ -632,7 +632,7 @@ hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe)
fe->face_destroy_func = _hb_qt_face_release;
}
return hb_face_reference((hb_face_t *)fe->face_);
return (hb_face_t *)fe->face_;
}
@ -645,8 +645,6 @@ _hb_qt_font_create(QFontEngine *fe)
hb_font_t *font = hb_font_create(face);
hb_face_destroy(face); // ref-ed in hb_qt_face_get_for_engine()
if (Q_UNLIKELY(hb_font_is_immutable(font))) {
hb_font_destroy(font);
return NULL;
@ -684,7 +682,7 @@ hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe)
fe->font_destroy_func = _hb_qt_font_release;
}
return hb_font_reference((hb_font_t *)fe->font_);
return (hb_font_t *)fe->font_;
}
QT_END_NAMESPACE

View File

@ -1168,8 +1168,6 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st
};
const int num_features = 1;
shapedOk = hb_shape_full(hb_font, buffer, features, num_features, 0);
hb_font_destroy(hb_font);
}
if (!shapedOk) {
hb_buffer_destroy(buffer);