mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
DropShadower: Fix crash due to IsWindowOnCurrentVirtualDesktop() causing synchronous repaint messages during component destruction on Windows
This commit is contained in:
parent
61fdde7cf9
commit
27e75a7059
2 changed files with 17 additions and 6 deletions
|
|
@ -75,8 +75,8 @@ private:
|
|||
JUCE_DECLARE_NON_COPYABLE (ShadowWindow)
|
||||
};
|
||||
|
||||
class ParentVisibilityChangedListener : public ComponentListener,
|
||||
private Timer
|
||||
class DropShadower::ParentVisibilityChangedListener : public ComponentListener,
|
||||
private Timer
|
||||
{
|
||||
public:
|
||||
ParentVisibilityChangedListener (Component& r, ComponentListener& l)
|
||||
|
|
@ -86,7 +86,10 @@ public:
|
|||
updateParentHierarchy (firstParent);
|
||||
|
||||
if ((SystemStats::getOperatingSystemType() & SystemStats::Windows) != 0)
|
||||
startTimerHz (20);
|
||||
{
|
||||
isOnVirtualDesktop = isWindowOnCurrentVirtualDesktop (root->getWindowHandle());
|
||||
startTimerHz (5);
|
||||
}
|
||||
}
|
||||
|
||||
~ParentVisibilityChangedListener() override
|
||||
|
|
@ -108,6 +111,8 @@ public:
|
|||
updateParentHierarchy (firstParent);
|
||||
}
|
||||
|
||||
bool isWindowOnVirtualDesktop() const noexcept { return isOnVirtualDesktop; }
|
||||
|
||||
private:
|
||||
class ComponentWithWeakReference
|
||||
{
|
||||
|
|
@ -152,12 +157,17 @@ private:
|
|||
|
||||
void timerCallback() override
|
||||
{
|
||||
listener->componentVisibilityChanged (*root);
|
||||
const auto wasOnVirtualDesktop = std::exchange (isOnVirtualDesktop,
|
||||
isWindowOnCurrentVirtualDesktop (root->getWindowHandle()));
|
||||
|
||||
if (isOnVirtualDesktop != wasOnVirtualDesktop)
|
||||
listener->componentVisibilityChanged (*root);
|
||||
}
|
||||
|
||||
Component* root = nullptr;
|
||||
ComponentListener* listener = nullptr;
|
||||
std::set<ComponentWithWeakReference> observedComponents;
|
||||
bool isOnVirtualDesktop = true;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (ParentVisibilityChangedListener)
|
||||
JUCE_DECLARE_NON_MOVEABLE (ParentVisibilityChangedListener)
|
||||
|
|
@ -259,7 +269,7 @@ void DropShadower::updateShadows()
|
|||
&& owner->isShowing()
|
||||
&& owner->getWidth() > 0 && owner->getHeight() > 0
|
||||
&& (Desktop::canUseSemiTransparentWindows() || owner->getParentComponent() != nullptr)
|
||||
&& isWindowOnCurrentVirtualDesktop (owner->getWindowHandle()))
|
||||
&& (visibilityChangedListener != nullptr && visibilityChangedListener->isWindowOnVirtualDesktop()))
|
||||
{
|
||||
while (shadowWindows.size() < 4)
|
||||
shadowWindows.add (new ShadowWindow (owner, shadow));
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ private:
|
|||
void updateParent();
|
||||
void updateShadows();
|
||||
|
||||
std::unique_ptr<ComponentListener> visibilityChangedListener;
|
||||
class ParentVisibilityChangedListener;
|
||||
std::unique_ptr<ParentVisibilityChangedListener> visibilityChangedListener;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DropShadower)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue