Skip to content

Commit

Permalink
Add JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (#4789)
Browse files Browse the repository at this point in the history
Add above to our custom widgets and adjust. Doesn't change
anything since I had memory management right but if it
breaks in the future etc...

Closes #4786
  • Loading branch information
baconpaul authored Jul 29, 2021
1 parent a3b1018 commit 0db17b2
Show file tree
Hide file tree
Showing 26 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/gui/overlays/AboutScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ struct AboutScreen : public juce::Component,
std::unique_ptr<juce::Button> copyButton;

juce::Colour fillColour{juce::Colour(0, 0, 0).withAlpha(0.8f)};

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AboutScreen);
};
} // namespace Overlays
} // namespace Surge
Expand Down
6 changes: 6 additions & 0 deletions src/gui/overlays/LuaEditors.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class CodeEditorContainerWithApply : public juce::Component,
SurgeStorage *storage;

virtual void applyCode() = 0;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CodeEditorContainerWithApply);
};

class FormulaModulatorEditor : public CodeEditorContainerWithApply
Expand All @@ -73,6 +75,8 @@ class FormulaModulatorEditor : public CodeEditorContainerWithApply
void applyCode() override;

FormulaModulatorStorage *formulastorage;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FormulaModulatorEditor);
};

class WavetablePreviewComponent;
Expand Down Expand Up @@ -108,6 +112,8 @@ class WavetableEquationEditor : public CodeEditorContainerWithApply,
void buttonClicked(juce::Button *button) override;

OscillatorStorage *osc;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WavetableEquationEditor);
};

} // namespace Overlays
Expand Down
2 changes: 2 additions & 0 deletions src/gui/overlays/MSEGEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct MSEGEditor : public juce::Component,

std::unique_ptr<MSEGControlRegion> controls;
std::unique_ptr<MSEGCanvas> canvas;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MSEGEditor);
};
} // namespace Overlays
} // namespace Surge
2 changes: 2 additions & 0 deletions src/gui/overlays/MiniEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ struct MiniEdit : public juce::Component,
void textEditorEscapeKeyPressed(juce::TextEditor &editor) override;
void textEditorReturnKeyPressed(juce::TextEditor &editor) override;
void grabFocus() { typein->grabKeyboardFocus(); }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MiniEdit);
};
} // namespace Overlays
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/overlays/ModulationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ModulationEditor : public juce::Component

void paint(juce::Graphics &g) override;
void resized() override;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationEditor);
};

} // namespace Overlays
Expand Down
2 changes: 2 additions & 0 deletions src/gui/overlays/OverlayWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ struct OverlayWrapper : public juce::Component,

std::function<void()> closeOverlay = []() {};
void setCloseOverlay(std::function<void()> f) { closeOverlay = std::move(f); }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OverlayWrapper);
};
} // namespace Overlays
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/overlays/PatchDBViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class PatchDBViewer : public juce::Component, public juce::TextEditor::Listener

SurgeStorage *storage;
SurgeGUIEditor *editor;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PatchDBViewer);
};

} // namespace Overlays
Expand Down
2 changes: 2 additions & 0 deletions src/gui/overlays/PatchStoreDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct PatchStoreDialog : public juce::Component,
std::unique_ptr<juce::TextButton> okButton, cancelButton;
std::unique_ptr<juce::ToggleButton> storeTuningButton;
std::unique_ptr<juce::Label> storeTuningLabel;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PatchStoreDialog);
};
} // namespace Overlays
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/overlays/TypeinParamEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ struct TypeinParamEditor : public juce::Component,
// Text editor listener methods
void textEditorReturnKeyPressed(juce::TextEditor &editor) override;
void textEditorEscapeKeyPressed(juce::TextEditor &editor) override;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TypeinParamEditor);
};
} // namespace Overlays
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/EffectChooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ struct EffectChooser : public juce::Component, public WidgetBaseMixin<EffectChoo

void getColorsForSlot(int fxslot, juce::Colour &bgcol, juce::Colour &frcol,
juce::Colour &txtcol);

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EffectChooser);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/EffectLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct EffectLabel : public juce::Component, public Surge::GUI::SkinConsumingCom
g.setFont(Surge::GUI::getFontManager()->displayFont);
g.drawText(label, getLocalBounds(), juce::Justification::centredLeft);
}

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EffectLabel);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/LFOAndStepDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ struct LFOAndStepDisplay : public juce::Component, public WidgetBaseMixin<LFOAnd
juce::Rectangle<float> ss_shift_left, ss_shift_right;
int lfoTypeHover{-1};
int ss_shift_hover{-1};

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LFOAndStepDisplay);
};
} // namespace Widgets
} // namespace Surge
Expand Down
3 changes: 3 additions & 0 deletions src/gui/widgets/MainFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace Widgets
{
struct MainFrame : public juce::Component
{
MainFrame() : juce::Component() {}
SurgeGUIEditor *editor{nullptr};
void setSurgeGUIEditor(SurgeGUIEditor *e) { editor = e; }

Expand All @@ -44,6 +45,8 @@ struct MainFrame : public juce::Component
}

void mouseDown(const juce::MouseEvent &event) override;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainFrame);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/MenuForDiscreteParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ struct MenuForDiscreteParams : public juce::Component,
void setStorage(SurgeStorage *s) { storage = s; }

float nextValueInOrder(float v, int inc);

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MenuForDiscreteParams);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/ModulatableSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ struct ModulatableSlider : public juce::Component,
juce::Rectangle<int> handleSize;
// Where do we position the tray relative to local bounds?
juce::AffineTransform trayPosition;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulatableSlider);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/ModulationSourceButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ struct ModulationSourceButton : public juce::Component,
void mouseDrag(const juce::MouseEvent &event) override;
void mouseWheelMove(const juce::MouseEvent &event,
const juce::MouseWheelDetails &wheel) override;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationSourceButton);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/MultiSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct MultiSwitch : public juce::Component, public WidgetBaseMixin<MultiSwitch>
void setSwitchDrawable(SurgeImage *d) { switchD = d; }
void setHoverSwitchDrawable(SurgeImage *d) { hoverSwitchD = d; }
void setHoverOnSwitchDrawable(SurgeImage *d) { hoverOnSwitchD = d; }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MultiSwitch);
};
} // namespace Widgets
} // namespace Surge
Expand Down
4 changes: 4 additions & 0 deletions src/gui/widgets/NumberField.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace Widgets
{
struct NumberField : public juce::Component, public WidgetBaseMixin<NumberField>
{
NumberField() : juce::Component(), WidgetBaseMixin<NumberField>() {}

SurgeStorage *storage{nullptr};
void setStorage(SurgeStorage *s) { storage = s; }

Expand Down Expand Up @@ -119,6 +121,8 @@ struct NumberField : public juce::Component, public WidgetBaseMixin<NumberField>
textHoverColour = c;
repaint();
}

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NumberField);
};

} // namespace Widgets
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/OscillatorWaveformDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ struct OscillatorWaveformDisplay : public juce::Component, public Surge::GUI::Sk
void dismissCustomEditor();
void drawEditorBox(juce::Graphics &g, const std::string &s);
std::unique_ptr<juce::Component> customEditor;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OscillatorWaveformDisplay);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/ParameterInfowindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ struct ParameterInfowindow : public juce::Component, public Surge::GUI::SkinCons
}
void doHide(int afterIdles = -1);
void idle();

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ParameterInfowindow);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/PatchSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ struct PatchSelector : public juce::Component, public WidgetBaseMixin<PatchSelec
*/
bool populatePatchMenuForCategory(int index, juce::PopupMenu &contextMenu, bool single_category,
int &main_e, bool rootCall);

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PatchSelector);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/Switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ struct Switch : public juce::Component, public WidgetBaseMixin<Switch>
SurgeImage *switchD{nullptr}, *hoverSwitchD{nullptr};
void setSwitchDrawable(SurgeImage *d) { switchD = d; }
void setHoverSwitchDrawable(SurgeImage *d) { hoverSwitchD = d; }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Switch);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/VerticalLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ struct VerticalLabel : public juce::Component
fontColour = f;
repaint();
}

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VerticalLabel);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/VuMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct VuMeter : public juce::Component, public WidgetBaseMixin<VuMeter>

void onSkinChanged() override;
SurgeImage *hVuBars;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VuMeter);
};
} // namespace Widgets
} // namespace Surge
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/WaveShaperSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ struct WaveShaperSelector : public juce::Component, public WidgetBaseMixin<WaveS
juce::Rectangle<int> buttonM, buttonP, buttonA, waveArea;

static std::array<std::vector<std::pair<float, float>>, n_ws_types> wsCurves;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WaveShaperSelector);
};

} // namespace Widgets
Expand Down
4 changes: 4 additions & 0 deletions src/gui/widgets/XMLConfiguredMenus.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ struct OscillatorMenu : public juce::Component,

int font_size{8}, text_hoffset{0}, text_voffset{0};
juce::Justification text_align{juce::Justification::centred};

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OscillatorMenu);
};

struct FxMenu : public juce::Component, public XMLMenuPopulator, public WidgetBaseMixin<FxMenu>
Expand Down Expand Up @@ -201,6 +203,8 @@ struct FxMenu : public juce::Component, public XMLMenuPopulator, public WidgetBa
SurgeImage *bg{}, *bgHover{};
void setBackgroundDrawable(SurgeImage *b) { bg = b; };
void setHoverBackgroundDrawable(SurgeImage *bgh) { bgHover = bgh; }

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxMenu);
};
} // namespace Widgets
} // namespace Surge
Expand Down

0 comments on commit 0db17b2

Please sign in to comment.