mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-03 03:30:06 +00:00
Minor fixes for LeakedObjectDetector, Slider, NamedValueSet.
This commit is contained in:
parent
5c1fda8261
commit
f1a0c50aeb
7 changed files with 122 additions and 135 deletions
|
|
@ -146,7 +146,7 @@ bool NamedValueSet::set (const Identifier& name, const var& newValue)
|
|||
|
||||
if (v->name == name)
|
||||
{
|
||||
if (v->value == newValue)
|
||||
if (v->value.equalsWithSameType (newValue))
|
||||
return false;
|
||||
|
||||
v->value = newValue;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
#define JUCE_MAJOR_VERSION 1
|
||||
#define JUCE_MINOR_VERSION 53
|
||||
#define JUCE_BUILDNUMBER 40
|
||||
#define JUCE_BUILDNUMBER 41
|
||||
|
||||
/** Current Juce version number.
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,12 @@ BEGIN_JUCE_NAMESPACE
|
|||
|
||||
|
||||
//==============================================================================
|
||||
class SliderPopupDisplayComponent : public BubbleComponent
|
||||
class Slider::PopupDisplayComponent : public BubbleComponent,
|
||||
public Timer
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
SliderPopupDisplayComponent (Slider* const owner_)
|
||||
PopupDisplayComponent (Slider& owner_)
|
||||
: owner (owner_),
|
||||
font (15.0f, Font::bold)
|
||||
{
|
||||
|
|
@ -70,15 +71,21 @@ public:
|
|||
repaint();
|
||||
}
|
||||
|
||||
BubbleComponent::setPosition (owner);
|
||||
BubbleComponent::setPosition (&owner);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void timerCallback()
|
||||
{
|
||||
owner.popupDisplay = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Slider* owner;
|
||||
Slider& owner;
|
||||
Font font;
|
||||
String text;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SliderPopupDisplayComponent);
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PopupDisplayComponent);
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -118,7 +125,6 @@ Slider::Slider (const String& name)
|
|||
menuShown (false),
|
||||
scrollWheelEnabled (true),
|
||||
snapsToMousePos (true),
|
||||
popupDisplay (0),
|
||||
parentForPopupDisplay (0)
|
||||
{
|
||||
setWantsKeyboardFocus (false);
|
||||
|
|
@ -491,12 +497,7 @@ void Slider::setValue (double newValue,
|
|||
repaint();
|
||||
|
||||
if (popupDisplay != 0)
|
||||
{
|
||||
static_cast <SliderPopupDisplayComponent*> (static_cast <Component*> (popupDisplay))
|
||||
->updatePosition (getTextFromValue (newValue));
|
||||
|
||||
popupDisplay->repaint();
|
||||
}
|
||||
popupDisplay->updatePosition (getTextFromValue (newValue));
|
||||
|
||||
if (sendUpdateMessage)
|
||||
triggerChangeMessage (sendMessageSynchronously);
|
||||
|
|
@ -551,12 +552,7 @@ void Slider::setMinValue (double newValue, const bool sendUpdateMessage, const b
|
|||
repaint();
|
||||
|
||||
if (popupDisplay != 0)
|
||||
{
|
||||
static_cast <SliderPopupDisplayComponent*> (static_cast <Component*> (popupDisplay))
|
||||
->updatePosition (getTextFromValue (newValue));
|
||||
|
||||
popupDisplay->repaint();
|
||||
}
|
||||
popupDisplay->updatePosition (getTextFromValue (newValue));
|
||||
|
||||
if (sendUpdateMessage)
|
||||
triggerChangeMessage (sendMessageSynchronously);
|
||||
|
|
@ -593,12 +589,7 @@ void Slider::setMaxValue (double newValue, const bool sendUpdateMessage, const b
|
|||
repaint();
|
||||
|
||||
if (popupDisplay != 0)
|
||||
{
|
||||
static_cast <SliderPopupDisplayComponent*> (static_cast <Component*> (popupDisplay))
|
||||
->updatePosition (getTextFromValue (valueMax.getValue()));
|
||||
|
||||
popupDisplay->repaint();
|
||||
}
|
||||
popupDisplay->updatePosition (getTextFromValue (valueMax.getValue()));
|
||||
|
||||
if (sendUpdateMessage)
|
||||
triggerChangeMessage (sendMessageSynchronously);
|
||||
|
|
@ -1111,17 +1102,13 @@ void Slider::mouseDown (const MouseEvent& e)
|
|||
|
||||
if (popupDisplayEnabled)
|
||||
{
|
||||
SliderPopupDisplayComponent* const popup = new SliderPopupDisplayComponent (this);
|
||||
PopupDisplayComponent* const popup = new PopupDisplayComponent (*this);
|
||||
popupDisplay = popup;
|
||||
|
||||
if (parentForPopupDisplay != 0)
|
||||
{
|
||||
parentForPopupDisplay->addChildComponent (popup);
|
||||
}
|
||||
else
|
||||
{
|
||||
popup->addToDesktop (0);
|
||||
}
|
||||
|
||||
popup->setVisible (true);
|
||||
}
|
||||
|
|
@ -1146,6 +1133,7 @@ void Slider::mouseUp (const MouseEvent&)
|
|||
triggerChangeMessage (false);
|
||||
|
||||
sendDragEnd();
|
||||
popupDisplay = 0;
|
||||
|
||||
if (style == IncDecButtons)
|
||||
{
|
||||
|
|
@ -1153,8 +1141,10 @@ void Slider::mouseUp (const MouseEvent&)
|
|||
decButton->setState (Button::buttonNormal);
|
||||
}
|
||||
}
|
||||
|
||||
popupDisplay = 0;
|
||||
else if (popupDisplay != 0)
|
||||
{
|
||||
popupDisplay->startTimer (2000);
|
||||
}
|
||||
}
|
||||
|
||||
void Slider::restoreMouseIfHidden()
|
||||
|
|
|
|||
|
|
@ -845,7 +845,11 @@ private:
|
|||
bool scrollWheelEnabled : 1, snapsToMousePos : 1;
|
||||
ScopedPointer<Label> valueBox;
|
||||
ScopedPointer<Button> incButton, decButton;
|
||||
ScopedPointer <Component> popupDisplay;
|
||||
|
||||
class PopupDisplayComponent;
|
||||
friend class PopupDisplayComponent;
|
||||
friend class ScopedPointer <PopupDisplayComponent>;
|
||||
ScopedPointer <PopupDisplayComponent> popupDisplay;
|
||||
Component* parentForPopupDisplay;
|
||||
|
||||
float getLinearSliderPos (double value);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public:
|
|||
{
|
||||
if (--(getCounter().numObjects) < 0)
|
||||
{
|
||||
DBG ("*** Dangling pointer deletion! Class: " << OwnerClass::getLeakedObjectClassName());
|
||||
DBG ("*** Dangling pointer deletion! Class: " << getLeakedObjectClassName());
|
||||
|
||||
/** If you hit this, then you've managed to delete more instances of this class than you've
|
||||
created.. That indicates that you're deleting some dangling pointers.
|
||||
|
|
@ -77,13 +77,13 @@ private:
|
|||
class LeakCounter
|
||||
{
|
||||
public:
|
||||
LeakCounter() {}
|
||||
LeakCounter() throw() {}
|
||||
|
||||
~LeakCounter()
|
||||
{
|
||||
if (numObjects.value > 0)
|
||||
{
|
||||
DBG ("*** Leaked objects detected: " << numObjects.value << " instance(s) of class " << OwnerClass::getLeakedObjectClassName());
|
||||
DBG ("*** Leaked objects detected: " << numObjects.value << " instance(s) of class " << getLeakedObjectClassName());
|
||||
|
||||
/** If you hit this, then you've leaked one or more objects of the type specified by
|
||||
the 'OwnerClass' template parameter - the name should have been printed by the line above.
|
||||
|
|
@ -99,6 +99,11 @@ private:
|
|||
Atomic<int> numObjects;
|
||||
};
|
||||
|
||||
static const char* getLeakedObjectClassName()
|
||||
{
|
||||
return OwnerClass::getLeakedObjectClassName();
|
||||
}
|
||||
|
||||
static LeakCounter& getCounter() throw()
|
||||
{
|
||||
static LeakCounter counter;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue