diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-12-08 13:58:13 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-12-09 16:53:37 +0100 |
commit | a6436ff5592332d5d06c6ee1806dc132306d5f3e (patch) | |
tree | 0ea2ee6429d709b6c4703cc078e9559271605fac /src | |
parent | 9ccd359be8a3fa1a050f839f99ce5f00aa2c9ea6 (diff) |
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>
Diffstat (limited to 'src')
-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(); } |