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:
@@ -22,7 +22,7 @@ class wxDisplayFactory
|
||||
{
|
||||
public:
|
||||
wxDisplayFactory() { }
|
||||
virtual ~wxDisplayFactory();
|
||||
virtual ~wxDisplayFactory() { ClearImpls(); }
|
||||
|
||||
// Create the display if necessary using CreateDisplay(), otherwise just
|
||||
// get it from cache.
|
||||
@@ -48,6 +48,9 @@ public:
|
||||
// the window pointer must not be NULL (i.e. caller should check it)
|
||||
virtual int GetFromWindow(const wxWindow *window);
|
||||
|
||||
// Trigger recreation of wxDisplayImpl when they're needed the next time.
|
||||
void InvalidateCache() { ClearImpls(); }
|
||||
|
||||
protected:
|
||||
// create a new display object
|
||||
//
|
||||
@@ -55,6 +58,9 @@ protected:
|
||||
virtual wxDisplayImpl *CreateDisplay(unsigned n) = 0;
|
||||
|
||||
private:
|
||||
// Delete all the elements of m_impls vector and clear it.
|
||||
void ClearImpls();
|
||||
|
||||
// On-demand populated vector of wxDisplayImpl objects.
|
||||
wxVector<wxDisplayImpl*> m_impls;
|
||||
|
||||
|
Reference in New Issue
Block a user