1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fix crash occurring in VirtualDesktopWatcher during desktop scaling changes

This commit is contained in:
attila 2023-08-13 19:21:27 +02:00
parent 19ba6bf193
commit e4c87b766b

View file

@ -131,17 +131,25 @@ private:
//==============================================================================
void update()
{
const auto newHasReasonToHide = [this]()
{
if (! component.wasObjectDeleted() && isWindows && component->isOnDesktop())
{
startTimerHz (5);
return ! detail::WindowingHelpers::isWindowOnCurrentVirtualDesktop (component->getWindowHandle());
}
bool newHasReasonToHide = false;
if (! component.wasObjectDeleted() && isWindows && component->isOnDesktop())
{
startTimerHz (5);
WeakReference<VirtualDesktopWatcher> weakThis (this);
// During scaling changes this call can trigger a call to HWNDComponentPeer::handleDPIChanging()
// which deletes this VirtualDesktopWatcher.
newHasReasonToHide = ! detail::WindowingHelpers::isWindowOnCurrentVirtualDesktop (component->getWindowHandle());
if (weakThis == nullptr)
return;
}
else
{
stopTimer();
return false;
}();
}
if (std::exchange (hasReasonToHide, newHasReasonToHide) != newHasReasonToHide)
for (auto& l : listeners)
@ -158,6 +166,8 @@ private:
const bool isWindows = (SystemStats::getOperatingSystemType() & SystemStats::Windows) != 0;
bool hasReasonToHide = false;
std::map<void*, std::function<void()>> listeners;
JUCE_DECLARE_WEAK_REFERENCEABLE (VirtualDesktopWatcher)
};
class DropShadower::ParentVisibilityChangedListener : public ComponentListener