Skip to content

Commit e487c69

Browse files
committed
Fix colour picker assertion at shutdown
1 parent 76ea282 commit e487c69

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

Source/Components/ColourPicker.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class Eyedropper final : public Timer
173173
PluginEditor* editor;
174174
};
175175

176-
class ColourPicker final : public Component {
176+
class ColourPicker final : public Component, public DeletedAtShutdown {
177177
class SelectorHolder final : public Component {
178178
public:
179179
explicit SelectorHolder(ColourPicker* parent)
@@ -298,14 +298,10 @@ class ColourPicker final : public Component {
298298
lookAndFeelChanged();
299299
}
300300

301-
static ColourPicker& getInstance()
302-
{
303-
static ColourPicker instance;
304-
return instance;
301+
~ColourPicker() override {
302+
clearSingletonInstance();
305303
}
306304

307-
~ColourPicker() override { }
308-
309305
void lookAndFeelChanged() override
310306
{
311307
for (auto* slider : sliders) {
@@ -780,4 +776,6 @@ class ColourPicker final : public Component {
780776
std::function<void(Colour)> callback = [](Colour) { };
781777

782778
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ColourPicker)
779+
public:
780+
JUCE_DECLARE_SINGLETON_INLINE(ColourPicker, false)
783781
};

Source/Components/PropertiesPanel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ void PropertiesPanel::InspectorColourComponent::mouseDown(MouseEvent const& e)
520520
if (e.x > getWidth() - 28) {
521521
auto const pickerBounds = getScreenBounds().withTrimmedLeft(getWidth() / 2).expanded(5);
522522

523-
ColourPicker::getInstance().show(findParentComponentOfClass<PluginEditor>(), getTopLevelComponent(), false, Colour::fromString(currentColour.toString()), pickerBounds, [_this = SafePointer(this)](Colour const c) {
523+
ColourPicker::getInstance()->show(findParentComponentOfClass<PluginEditor>(), getTopLevelComponent(), false, Colour::fromString(currentColour.toString()), pickerBounds, [_this = SafePointer(this)](Colour const c) {
524524
if (!_this)
525525
return;
526526

@@ -577,7 +577,7 @@ class SwatchComponent final : public Component {
577577
void mouseDown(MouseEvent const& e) override
578578
{
579579
auto const pickerBounds = getScreenBounds().expanded(5);
580-
ColourPicker::getInstance().show(findParentComponentOfClass<PluginEditor>(), getTopLevelComponent(), false, Colour::fromString(colourValue.toString()), pickerBounds, [_this = SafePointer(this)](Colour const c) {
580+
ColourPicker::getInstance()->show(findParentComponentOfClass<PluginEditor>(), getTopLevelComponent(), false, Colour::fromString(colourValue.toString()), pickerBounds, [_this = SafePointer(this)](Colour const c) {
581581
if (!_this)
582582
return;
583583

Source/Objects/ColourPickerObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ColourPickerObject final : public TextObjectBase {
3434
sscanf(colors->x_color, "#%02x%02x%02x", &red, &green, &blue);
3535
}
3636

37-
ColourPicker::getInstance().show(findParentComponentOfClass<PluginEditor>(), getTopLevelComponent(), true, Colour(red, green, blue), Rectangle<int>(1, 1).withPosition(Desktop::getInstance().getMousePosition()), [_this = SafePointer(this)](Colour const c) {
37+
ColourPicker::getInstance()->show(findParentComponentOfClass<PluginEditor>(), getTopLevelComponent(), true, Colour(red, green, blue), Rectangle<int>(1, 1).withPosition(Desktop::getInstance().getMousePosition()), [_this = SafePointer(this)](Colour const c) {
3838
if (!_this)
3939
return;
4040

0 commit comments

Comments
 (0)