Invalidate wxDisplay cache under MSW when the displays change

The cache added in 990c8bfd73 was not
invalidated properly, meaning that wrong information was returned when
displays were [dis]connected after the application startup.

Fix this at least for MSW by invalidating the cache on receiving
WM_DISPLAYCHANGE (which means that sometimes we will do it
unnecessarily, as the change in resolution of an existing display
doesn't require cache invalidation, but this shouldn't be a big problem
in practice as the speed with which the user can change the display
resolution is not very high).

Closes https://github.com/wxWidgets/wxWidgets/pull/1090
This commit is contained in:
Vadim Zeitlin
2018-12-18 23:39:10 +01:00
parent 7f63adde95
commit 22c18a107e
4 changed files with 24 additions and 3 deletions

View File

@@ -113,6 +113,11 @@ wxDisplay::wxDisplay(const wxWindow* window)
return Factory().GetFromWindow(window);
}
/* static */ void wxDisplay::InvalidateCache()
{
Factory().InvalidateCache();
}
// ----------------------------------------------------------------------------
// functions forwarded to wxDisplayImpl
// ----------------------------------------------------------------------------
@@ -229,13 +234,15 @@ wxSize wxDisplayImpl::GetPPI() const
// wxDisplayFactory implementation
// ============================================================================
wxDisplayFactory::~wxDisplayFactory()
void wxDisplayFactory::ClearImpls()
{
for ( size_t n = 0; n < m_impls.size(); ++n )
{
// It can be null, that's ok.
delete m_impls[n];
}
m_impls.clear();
}
int wxDisplayFactory::GetFromWindow(const wxWindow *window)