diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index efced94397..a7868f36ab 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -722,14 +722,19 @@ QStaticTextItem::~QStaticTextItem() { if (m_userData != 0 && !m_userData->ref.deref()) delete m_userData; - m_fontEngine->ref.deref(); + setFontEngine(0); } void QStaticTextItem::setFontEngine(QFontEngine *fe) { - if (m_fontEngine != 0) - m_fontEngine->ref.deref(); + if (m_fontEngine == fe) + return; + + if (m_fontEngine != 0 && !m_fontEngine->ref.deref()) + delete m_fontEngine; + m_fontEngine = fe; + if (m_fontEngine != 0) m_fontEngine->ref.ref(); }