diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-08-04 11:17:47 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-08-04 11:17:47 (GMT) |
commit | be212bf108e71ba3b5b75802b1f4de6613ba315c (patch) | |
tree | c541ad12e8698f04e8fe386c2e1b94e8baca6c1b /src/gui/text/qfontengine_ft.cpp | |
parent | 67ae1b0dac175f48875507f3187ed49276a29ddf (diff) | |
parent | e6bb00250b321b149dd80259dc4f479088d5949b (diff) | |
download | Qt-be212bf108e71ba3b5b75802b1f4de6613ba315c.zip Qt-be212bf108e71ba3b5b75802b1f4de6613ba315c.tar.gz Qt-be212bf108e71ba3b5b75802b1f4de6613ba315c.tar.bz2 |
Merge commit 'origin/master'
Conflicts:
src/corelib/global/qglobal.h
src/corelib/kernel/qmetatype.cpp
src/corelib/kernel/qobject.cpp
src/corelib/thread/qthread_unix.cpp
src/gui/graphicsview/qgraphicssceneevent.h
src/gui/itemviews/qheaderview.h
src/gui/kernel/qapplication_qws.cpp
src/gui/kernel/qgesture.h
src/gui/kernel/qgesturerecognizer.h
src/gui/painting/qpaintengine_raster.cpp
src/network/access/qhttpnetworkreply.cpp
src/network/access/qnetworkcookie.h
src/network/socket/qnativesocketengine_unix.cpp
Diffstat (limited to 'src/gui/text/qfontengine_ft.cpp')
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 499d28c..4c4438a 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -205,7 +205,9 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id) FT_Init_FreeType(&freetypeData->library); QFreetypeFace *freetype = freetypeData->faces.value(face_id, 0); - if (!freetype) { + if (freetype) { + freetype->ref.ref(); + } else { QScopedPointer<QFreetypeFace> newFreetype(new QFreetypeFace); FT_Face face; QFile file(QString::fromUtf8(face_id.filename)); @@ -234,7 +236,8 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id) newFreetype->face = face; newFreetype->hbFace = qHBNewFace(face, hb_getSFntTable); - newFreetype->ref = 0; + Q_CHECK_PTR(newFreetype->hbFace); + newFreetype->ref = 1; newFreetype->xsize = 0; newFreetype->ysize = 0; newFreetype->matrix.xx = 0x10000; @@ -289,10 +292,15 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id) #endif FT_Set_Charmap(newFreetype->face, newFreetype->unicode_map); - freetypeData->faces.insert(face_id, newFreetype.data()); + QT_TRY { + freetypeData->faces.insert(face_id, newFreetype.data()); + } QT_CATCH(...) { + newFreetype.take()->release(face_id); + // we could return null in principle instead of throwing + QT_RETHROW; + } freetype = newFreetype.take(); } - freetype->ref.ref(); return freetype; } @@ -306,7 +314,8 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id) if (charset) FcCharSetDestroy(charset); #endif - freetypeData->faces.take(face_id); + if(freetypeData->faces.contains(face_id)) + freetypeData->faces.take(face_id); delete this; } if (freetypeData->faces.isEmpty()) { |