Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
4.8.2
-
36cb3f3f655a9090c82de609010cbfb88651a0f3
Description
Sometimes I got memory leaks in QtGui (QtGui compiled with vs2010 and 'visual leak detector vld' included)
The reason is in function 'void QFontCache::timerEvent(QTimerEvent *)' in module 'qfont.cpp'
if (-it.value().data>cache_count == 0)
else
{ /* this particular font engine is in the cache multiple times... set current_cost to zero, so that we can keep looping to get rid of all occurrences */ current_cost = 0; }engineCache.erase(it);
Sometimes 'cache_count' is > 0 but font engine is !!not!! multiple times in cache, so the engine is erased from the cache, but the data is not deleted.
The reason for this could be in function 'void QFontDatabase::load(const QFontPrivate *d, int script)' in module 'qfontdatabase_win.cpp'
QFontEngine *fe = QFontCache::instance()->findEngine(key);
.
.
.
QFontCache::instance()->insertEngine(key, fe);
if 'fe' was found in the cache, no attemped should be made to insert it into the cache, because this will fail but 'cache_count' is inreased anyway.
In constructor of class 'QFontEngineDirectWrite' in module 'qfontenginedirectWrite.cpp' the member variable 'cache_cost' is not initialized.
It could be done with this rough estimate:
.
.
collectMetrics();
cache_cost = (m_ascent.toInt() + m_descent.toInt()) * m_xHeight.toInt() * 2000;
In function 'initFontInfo' in module 'qfontdatabase_win.cpp' I think you have to release the 'fontFamily' too (is done in Microsoft example).
.
.
delete[] name;
if (familyNames != 0)
familyNames->Release();
if (fontFamily != 0)
fontFamily->Release();