Browse Source

Added a check in Button to detect self-deletion as a side-effect of its toggle value changing

tags/2021-05-28
jules 9 years ago
parent
commit
9177a94b15
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      modules/juce_gui_basics/buttons/juce_Button.cpp

+ 9
- 2
modules/juce_gui_basics/buttons/juce_Button.cpp View File

@@ -175,8 +175,15 @@ void Button::setToggleState (const bool shouldBeOn, const NotificationType notif
return;
}
if (getToggleState() != shouldBeOn) // this test means that if the value is void rather than explicitly set to
isOn = shouldBeOn; // false, it won't be changed unless the required value is true.
// This test is done so that if the value is void rather than explicitly set to
// false, the value won't be changed unless the required value is true.
if (getToggleState() != shouldBeOn)
{
isOn = shouldBeOn;
if (deletionWatcher == nullptr)
return;
}
lastToggleState = shouldBeOn;
repaint();


Loading…
Cancel
Save