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:
parent
19ba6bf193
commit
e4c87b766b
1 changed files with 19 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue