Windows: Limit cursor cache.
Prevent the cursor cache from growing indefinitely hitting GDI resource limits if new pixmap cursors are created repetitively by purging out all-noncurrent pixmap cursors. Change-Id: I4a3bbd6235af13e306ca84ac6fea3fcd69d53279 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>bb10
parent
9ccd359be8
commit
a6436ff559
|
|
@ -570,8 +570,21 @@ QWindowsWindowCursor QWindowsCursor::pixmapWindowCursor(const QCursor &c)
|
|||
{
|
||||
const QWindowsCursorCacheKey cacheKey(c);
|
||||
CursorCache::iterator it = m_cursorCache.find(cacheKey);
|
||||
if (it == m_cursorCache.end())
|
||||
if (it == m_cursorCache.end()) {
|
||||
if (m_cursorCache.size() > 50) {
|
||||
// Prevent the cursor cache from growing indefinitely hitting GDI resource
|
||||
// limits if new pixmap cursors are created repetitively by purging out
|
||||
// all-noncurrent pixmap cursors (QTBUG-43515)
|
||||
const HCURSOR currentCursor = GetCursor();
|
||||
for (it = m_cursorCache.begin(); it != m_cursorCache.end() ; ) {
|
||||
if (it.key().bitmapCacheKey && it.value().handle() != currentCursor)
|
||||
it = m_cursorCache.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
it = m_cursorCache.insert(cacheKey, QWindowsWindowCursor(c));
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue