- // Reduce the number of bogus reports of non-freed memory
- // at app exit
- if (ms_cache.IsEmpty())
- ms_cache.Clear();
- }
- //else: cached DC entry is still in use
+ wxPaintDCInfo *info = FindInCache();
+ if ( info )
+ {
+ m_hDC = info->hdc;
+ info->count++;
+ }
+ else // not in cache, create a new one
+ {
+ m_hDC = dc;
+ ms_cache.Add(new wxPaintDCInfo(m_window, this));
+ m_saveState = SaveDC((HDC) dc);
+ }
+}
+
+wxPaintDCExImpl::~wxPaintDCExImpl()
+{
+ size_t index;
+ wxPaintDCInfo *info = FindInCache(&index);
+
+ wxCHECK_RET( info, wxT("existing DC should have a cache entry") );