diff options
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscursor.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index f5d6c140bf..d10c7fdb20 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -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(); } |