1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Add a base clang-tidy configuration

This commit is contained in:
Tom Poole 2023-09-11 20:49:49 +01:00
parent 0dfaa98e86
commit 9b041f3d74
73 changed files with 484 additions and 279 deletions

22
.clang-tidy Normal file
View file

@ -0,0 +1,22 @@
Checks: >
-clang-analyzer-cplusplus.NewDeleteLeaks,
-clang-analyzer-optin.performance.Padding,
-clang-analyzer-security.FloatLoopCounter,
-clang-analyzer-security.insecureAPI.strcpy,
WarningsAsErrors: '*'
# No negative lookahead available here, which makes things difficult.
#
# We want checks to run on JUCE files included from the JUCE modules. We can
# restrict these to files named `juce_.*`.
#
# We also want checks to run on any files inlcuded from the examples or extras
# directories. However, some include paths generated by the Android Studio build
# system look like:
#
# ~/JUCE/examples/DemoRunner/Builds/Android/app/../../../../../modules/juce_box2d/box2d/Collision/b2CollideEdge.cpp
#
# Since we can only opt-in to paths, we restrict the maximum depth of the path
# past examples/extras.
HeaderFilterRegex: '(.*\/modules\/juce_.*juce_[^\/]*$)|(\/(examples|extras)(\/[^\/]*){1,7}$)'

View file

@ -67,7 +67,7 @@ struct CodeContent : public Component
codeEditor.setReadOnly (true); codeEditor.setReadOnly (true);
codeEditor.setScrollbarThickness (8); codeEditor.setScrollbarThickness (8);
lookAndFeelChanged(); updateLookAndFeel();
} }
void resized() override void resized() override
@ -83,9 +83,9 @@ struct CodeContent : public Component
"*******************************************************************************/\n"); "*******************************************************************************/\n");
} }
void lookAndFeelChanged() override void updateLookAndFeel()
{ {
auto* v4 = dynamic_cast <LookAndFeel_V4*> (&Desktop::getInstance().getDefaultLookAndFeel()); auto* v4 = dynamic_cast<LookAndFeel_V4*> (&Desktop::getInstance().getDefaultLookAndFeel());
if (v4 != nullptr && (v4->getCurrentColourScheme() != LookAndFeel_V4::getLightColourScheme())) if (v4 != nullptr && (v4->getCurrentColourScheme() != LookAndFeel_V4::getLightColourScheme()))
codeEditor.setColourScheme (getDarkColourScheme()); codeEditor.setColourScheme (getDarkColourScheme());
@ -93,6 +93,11 @@ struct CodeContent : public Component
codeEditor.setColourScheme (getLightColourScheme()); codeEditor.setColourScheme (getLightColourScheme());
} }
void lookAndFeelChanged() override
{
updateLookAndFeel();
}
CodeDocument document; CodeDocument document;
CPlusPlusCodeTokeniser cppTokensier; CPlusPlusCodeTokeniser cppTokensier;
CodeEditorComponent codeEditor { document, &cppTokensier }; CodeEditorComponent codeEditor { document, &cppTokensier };
@ -115,7 +120,7 @@ DemoContentComponent::DemoContentComponent (Component& mainComponent, std::funct
addTab ("Settings", Colours::transparentBlack, new SettingsContent (dynamic_cast<MainComponent&> (mainComponent)), true); addTab ("Settings", Colours::transparentBlack, new SettingsContent (dynamic_cast<MainComponent&> (mainComponent)), true);
setTabBarDepth (40); setTabBarDepth (40);
lookAndFeelChanged(); updateLookAndFeel();
} }
DemoContentComponent::~DemoContentComponent() DemoContentComponent::~DemoContentComponent()
@ -182,7 +187,7 @@ void DemoContentComponent::clearCurrentDemo()
demoChangedCallback (false); demoChangedCallback (false);
} }
void DemoContentComponent::lookAndFeelChanged() void DemoContentComponent::updateLookAndFeel()
{ {
auto backgroundColour = findColour (ResizableWindow::backgroundColourId); auto backgroundColour = findColour (ResizableWindow::backgroundColourId);
@ -190,6 +195,11 @@ void DemoContentComponent::lookAndFeelChanged()
setTabBackgroundColour (i, backgroundColour); setTabBackgroundColour (i, backgroundColour);
} }
void DemoContentComponent::lookAndFeelChanged()
{
updateLookAndFeel();
}
String DemoContentComponent::trimPIP (const String& fileContents) String DemoContentComponent::trimPIP (const String& fileContents)
{ {
auto lines = StringArray::fromLines (fileContents); auto lines = StringArray::fromLines (fileContents);

View file

@ -63,6 +63,7 @@ private:
int tabBarIndent = 0; int tabBarIndent = 0;
//============================================================================== //==============================================================================
void updateLookAndFeel();
void lookAndFeelChanged() override; void lookAndFeelChanged() override;
String trimPIP (const String& fileContents); String trimPIP (const String& fileContents);

View file

@ -80,7 +80,7 @@ struct SidePanelHeader : public Component
addAndMakeVisible (settingsButton); addAndMakeVisible (settingsButton);
settingsButton.onClick = [this] { owner.settingsButtonClicked(); }; settingsButton.onClick = [this] { owner.settingsButtonClicked(); };
lookAndFeelChanged(); updateLookAndFeel();
} }
void paint (Graphics& g) override void paint (Graphics& g) override
@ -102,7 +102,7 @@ struct SidePanelHeader : public Component
titleLabel.setBounds (bounds); titleLabel.setBounds (bounds);
} }
void lookAndFeelChanged() override void updateLookAndFeel()
{ {
auto& sidePanel = owner.getSidePanel(); auto& sidePanel = owner.getSidePanel();
auto& lf = sidePanel.getLookAndFeel(); auto& lf = sidePanel.getLookAndFeel();
@ -117,6 +117,12 @@ struct SidePanelHeader : public Component
homeButton.setColours (normal, over, down); homeButton.setColours (normal, over, down);
settingsButton.setColours (normal, over, down); settingsButton.setColours (normal, over, down);
}
void lookAndFeelChanged() override
{
updateLookAndFeel();
} }
MainComponent& owner; MainComponent& owner;

View file

@ -422,8 +422,8 @@ private:
if (wi.get() != nullptr && wo.get() != nullptr) if (wi.get() != nullptr && wo.get() != nullptr)
{ {
auto numWritten = wo->writeFromInputStream (*wi, -1); [[maybe_unused]] auto numWritten = wo->writeFromInputStream (*wi, -1);
jassertquiet (numWritten > 0); jassert (numWritten > 0);
wo->flush(); wo->flush();
} }
} }

View file

@ -500,14 +500,14 @@ public:
currentScaleFactor = scale; currentScaleFactor = scale;
AudioProcessorEditor::setScaleFactor (scale); AudioProcessorEditor::setScaleFactor (scale);
const auto posted = MessageManager::callAsync ([ref = SafePointer<HostAudioProcessorEditor> (this), scale] [[maybe_unused]] const auto posted = MessageManager::callAsync ([ref = SafePointer<HostAudioProcessorEditor> (this), scale]
{ {
if (auto* r = ref.getComponent()) if (auto* r = ref.getComponent())
if (auto* e = r->currentEditorComponent) if (auto* e = r->currentEditorComponent)
e->setScaleFactor (scale); e->setScaleFactor (scale);
}); });
jassertquiet (posted); jassert (posted);
} }
private: private:
@ -520,8 +520,8 @@ private:
{ {
auto editorComponent = std::make_unique<PluginEditorComponent> (hostProcessor.createInnerEditor(), [this] auto editorComponent = std::make_unique<PluginEditorComponent> (hostProcessor.createInnerEditor(), [this]
{ {
const auto posted = MessageManager::callAsync ([this] { clearPlugin(); }); [[maybe_unused]] const auto posted = MessageManager::callAsync ([this] { clearPlugin(); });
jassertquiet (posted); jassert (posted);
}); });
editorComponent->setScaleFactor (currentScaleFactor); editorComponent->setScaleFactor (currentScaleFactor);

View file

@ -103,7 +103,7 @@ public:
if (auto* file = getAppProperties().getUserSettings()) if (auto* file = getAppProperties().getUserSettings())
file->addChangeListener (this); file->addChangeListener (this);
changeListenerCallback (nullptr); handleChange();
} }
~CustomPluginScanner() override ~CustomPluginScanner() override
@ -183,12 +183,17 @@ private:
} }
} }
void changeListenerCallback (ChangeBroadcaster*) override void handleChange()
{ {
if (auto* file = getAppProperties().getUserSettings()) if (auto* file = getAppProperties().getUserSettings())
scanInProcess = (file->getIntValue (scanModeKey) == 0); scanInProcess = (file->getIntValue (scanModeKey) == 0);
} }
void changeListenerCallback (ChangeBroadcaster*) override
{
handleChange();
}
std::unique_ptr<Superprocess> superprocess; std::unique_ptr<Superprocess> superprocess;
std::atomic<bool> scanInProcess { true }; std::atomic<bool> scanInProcess { true };
@ -226,10 +231,16 @@ public:
getAppProperties().getUserSettings()->setValue (scanModeKey, validationModeBox.getSelectedItemIndex()); getAppProperties().getUserSettings()->setValue (scanModeKey, validationModeBox.getSelectedItemIndex());
}; };
resized(); handleResize();
} }
void resized() override void resized() override
{
handleResize();
}
private:
void handleResize()
{ {
PluginListComponent::resized(); PluginListComponent::resized();
@ -237,7 +248,7 @@ public:
validationModeBox.setBounds (buttonBounds.withWidth (130).withRightX (getWidth() - buttonBounds.getX())); validationModeBox.setBounds (buttonBounds.withWidth (130).withRightX (getWidth() - buttonBounds.getX()));
} }
private:
Label validationModeLabel { {}, "Scan mode" }; Label validationModeLabel { {}, "Scan mode" };
ComboBox validationModeBox; ComboBox validationModeBox;

View file

@ -61,7 +61,7 @@ public:
OSCReceiver::addListener (this); OSCReceiver::addListener (this);
timerCallback(); handleTimerCallback();
startTimer (2000); startTimer (2000);
} }
@ -200,12 +200,18 @@ private:
return {}; return {};
} }
void timerCallback() override void handleTimerCallback()
{ {
send (newClientOSCAddress, clientName + ":" + IPAddress::getLocalAddress().toString() send (newClientOSCAddress, clientName + ":" + IPAddress::getLocalAddress().toString()
+ ":" + getScreenAreaInGlobalSpace().toString()); + ":" + getScreenAreaInGlobalSpace().toString());
} }
void timerCallback() override
{
handleTimerCallback();
}
void handleAsyncUpdate() override void handleAsyncUpdate() override
{ {
const ScopedLock sl (canvasLock); const ScopedLock sl (canvasLock);

View file

@ -82,7 +82,7 @@ public:
setWantsKeyboardFocus (true); setWantsKeyboardFocus (true);
setOpaque (true); setOpaque (true);
lookAndFeelChanged(); updateLookAndFeel();
setSize (300, 350); setSize (300, 350);
} }
@ -134,11 +134,16 @@ public:
URL ("https://juce.com/verification/register").launchInDefaultBrowser(); URL ("https://juce.com/verification/register").launchInDefaultBrowser();
} }
void lookAndFeelChanged() override void updateLookAndFeel()
{ {
enableGPLButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId)); enableGPLButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
} }
void lookAndFeelChanged() override
{
updateLookAndFeel();
}
private: private:
class ProgressButton : public TextButton, class ProgressButton : public TextButton,
private Timer private Timer

View file

@ -164,7 +164,7 @@ public:
juceIcon = Drawable::createFromImageData (BinaryData::juce_icon_png, juceIcon = Drawable::createFromImageData (BinaryData::juce_icon_png,
BinaryData::juce_icon_pngSize); BinaryData::juce_icon_pngSize);
lookAndFeelChanged(); updateLookAndFeel();
setSize (500, 280); setSize (500, 280);
} }
@ -218,12 +218,17 @@ public:
} }
private: private:
void lookAndFeelChanged() override void updateLookAndFeel()
{ {
cancelButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId)); cancelButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
releaseNotesEditor.applyFontToAllText (releaseNotesEditor.getFont()); releaseNotesEditor.applyFontToAllText (releaseNotesEditor.getFont());
} }
void lookAndFeelChanged() override
{
updateLookAndFeel();
}
void setParentWindow (DialogWindow* parent) void setParentWindow (DialogWindow* parent)
{ {
parentWindow = parent; parentWindow = parent;

View file

@ -52,7 +52,7 @@ public:
setVisible (true); setVisible (true);
static_cast<Component&> (mainWindow).addChildComponent (this); static_cast<Component&> (mainWindow).addChildComponent (this);
componentMovedOrResized (true, true); handleComponentMovedOrResized();
enterModalState(); enterModalState();
} }
@ -80,7 +80,9 @@ private:
void componentVisibilityChanged() override {} void componentVisibilityChanged() override {}
using ComponentMovementWatcher::componentVisibilityChanged; using ComponentMovementWatcher::componentVisibilityChanged;
void componentMovedOrResized (bool, bool) override { triggerAsyncUpdate(); } void handleComponentMovedOrResized() { triggerAsyncUpdate(); }
void componentMovedOrResized (bool, bool) override { handleComponentMovedOrResized(); }
using ComponentMovementWatcher::componentMovedOrResized; using ComponentMovementWatcher::componentMovedOrResized;
void handleAsyncUpdate() override { resized(); } void handleAsyncUpdate() override { resized(); }

View file

@ -36,7 +36,7 @@ public:
UnknownDocument (Project* p, const File& f) UnknownDocument (Project* p, const File& f)
: project (p), file (f) : project (p), file (f)
{ {
reloadFromFile(); handleReloadFromFile();
} }
//============================================================================== //==============================================================================
@ -57,7 +57,7 @@ public:
void saveAsync (std::function<void (bool)>) override {} void saveAsync (std::function<void (bool)>) override {}
void saveAsAsync (std::function<void (bool)>) override {} void saveAsAsync (std::function<void (bool)>) override {}
bool hasFileBeenModifiedExternally() override { return fileModificationTime != file.getLastModificationTime(); } bool hasFileBeenModifiedExternally() override { return fileModificationTime != file.getLastModificationTime(); }
void reloadFromFile() override { fileModificationTime = file.getLastModificationTime(); } void reloadFromFile() override { handleReloadFromFile(); }
String getName() const override { return file.getFileName(); } String getName() const override { return file.getFileName(); }
File getFile() const override { return file; } File getFile() const override { return file; }
std::unique_ptr<Component> createEditor() override { return std::make_unique<ItemPreviewComponent> (file); } std::unique_ptr<Component> createEditor() override { return std::make_unique<ItemPreviewComponent> (file); }
@ -76,6 +76,8 @@ public:
} }
private: private:
void handleReloadFromFile() { fileModificationTime = file.getLastModificationTime(); }
Project* const project; Project* const project;
File file; File file;
Time fileModificationTime; Time fileModificationTime;

View file

@ -294,7 +294,7 @@ public:
{ {
if (undoable) if (undoable)
{ {
layout.perform (new SetImageKeepsPropAction (button, layout, newState), "change imagebutton proportion mode"); layout.perform (std::make_unique<SetImageKeepsPropAction> (button, layout, newState), "change imagebutton proportion mode");
} }
else else
{ {
@ -371,7 +371,7 @@ public:
{ {
if (undoable) if (undoable)
{ {
layout.perform (new SetImageOpacityAction (button, layout, role, opacity), "change imagebutton opacity"); layout.perform (std::make_unique<SetImageOpacityAction> (button, layout, role, opacity), "change imagebutton opacity");
} }
else else
{ {
@ -453,7 +453,7 @@ public:
{ {
if (undoable) if (undoable)
{ {
layout.perform (new SetImageColourAction (button, layout, role, colour), "change imagebutton colour"); layout.perform (std::make_unique<SetImageColourAction> (button, layout, role, colour), "change imagebutton colour");
} }
else else
{ {

View file

@ -1017,6 +1017,7 @@ bool PaintElementPath::getPoint (int index, int pointNumber, double& x, double&
if (pointNumber >= PathPoint::maxRects) if (pointNumber >= PathPoint::maxRects)
{ {
jassertfalse; jassertfalse;
x = y = 0;
return false; return false;
} }

View file

@ -43,7 +43,7 @@ public:
PaintElementPath* owner; PaintElementPath* owner;
Path::Iterator::PathElementType type; Path::Iterator::PathElementType type;
RelativePositionedRectangle pos [maxRects]; RelativePositionedRectangle pos[maxRects] = {};
int getNumPoints() const; int getNumPoints() const;

View file

@ -422,15 +422,13 @@ public:
protected: protected:
class PositionPropLabel : public Label class PositionPropLabel : public Label
{ {
PositionPropertyBase& owner;
public: public:
PositionPropLabel (PositionPropertyBase& owner_) PositionPropLabel (PositionPropertyBase& owner_)
: Label (String(), String()), : Label (String(), String()),
owner (owner_) owner (owner_)
{ {
setEditable (true, true, false); setEditable (true, true, false);
lookAndFeelChanged(); updateLookAndFeel();
} }
TextEditor* createEditorComponent() override TextEditor* createEditorComponent() override
@ -447,10 +445,18 @@ protected:
} }
void lookAndFeelChanged() override void lookAndFeelChanged() override
{
updateLookAndFeel();
}
private:
void updateLookAndFeel()
{ {
setColour (backgroundColourId, findColour (widgetBackgroundColourId)); setColour (backgroundColourId, findColour (widgetBackgroundColourId));
setColour (textColourId, findColour (widgetTextColourId)); setColour (textColourId, findColour (widgetTextColourId));
} }
PositionPropertyBase& owner;
}; };
ComponentLayout* layout; ComponentLayout* layout;

View file

@ -47,7 +47,7 @@ ComponentOverlayComponent::ComponentOverlayComponent (Component* const target_,
target->addComponentListener (this); target->addComponentListener (this);
changeListenerCallback (nullptr); updateSelected();
layout.getSelectedSet().addChangeListener (this); layout.getSelectedSet().addChangeListener (this);
setRepaintsOnMouseActivity (true); setRepaintsOnMouseActivity (true);
@ -62,7 +62,7 @@ ComponentOverlayComponent::~ComponentOverlayComponent()
target->removeComponentListener (this); target->removeComponentListener (this);
} }
void ComponentOverlayComponent::changeListenerCallback (ChangeBroadcaster*) void ComponentOverlayComponent::updateSelected()
{ {
const bool nowSelected = layout.getSelectedSet().isSelected (target); const bool nowSelected = layout.getSelectedSet().isSelected (target);
@ -74,6 +74,11 @@ void ComponentOverlayComponent::changeListenerCallback (ChangeBroadcaster*)
} }
} }
void ComponentOverlayComponent::changeListenerCallback (ChangeBroadcaster*)
{
updateSelected();
}
void ComponentOverlayComponent::paint (Graphics& g) void ComponentOverlayComponent::paint (Graphics& g)
{ {
jassert (target != nullptr); jassert (target != nullptr);

View file

@ -73,6 +73,7 @@ private:
void componentMovedOrResized (Component&, bool wasMoved, bool wasResized) override; void componentMovedOrResized (Component&, bool wasMoved, bool wasResized) override;
void updateSelected();
void changeListenerCallback (ChangeBroadcaster*) override; void changeListenerCallback (ChangeBroadcaster*) override;
std::unique_ptr<ResizableBorderComponent> border; std::unique_ptr<ResizableBorderComponent> border;

View file

@ -34,13 +34,12 @@ public:
explicit MagnifierComponent (Component* c) : content (c) explicit MagnifierComponent (Component* c) : content (c)
{ {
addAndMakeVisible (content.get()); addAndMakeVisible (content.get());
childBoundsChanged (content.get()); updateBounds (content.get());
} }
void childBoundsChanged (Component* child) void childBoundsChanged (Component* child)
{ {
auto childArea = getLocalArea (child, child->getLocalBounds()); updateBounds (child);
setSize (childArea.getWidth(), childArea.getHeight());
} }
double getScaleFactor() const { return scaleFactor; } double getScaleFactor() const { return scaleFactor; }
@ -52,6 +51,12 @@ public:
} }
private: private:
void updateBounds (Component* child)
{
auto childArea = getLocalArea(child, child->getLocalBounds());
setSize (childArea.getWidth(), childArea.getHeight());
}
double scaleFactor = 1.0; double scaleFactor = 1.0;
std::unique_ptr<Component> content; std::unique_ptr<Component> content;
}; };

View file

@ -350,10 +350,10 @@ JucerDocumentEditor::JucerDocumentEditor (JucerDocument* const doc)
document->addChangeListener (this); document->addChangeListener (this);
resized(); handleResize();
refreshPropertiesPanel(); refreshPropertiesPanel();
changeListenerCallback (nullptr); handleChange();
} }
} }
@ -428,17 +428,27 @@ void JucerDocumentEditor::paint (Graphics& g)
g.fillAll (findColour (backgroundColourId)); g.fillAll (findColour (backgroundColourId));
} }
void JucerDocumentEditor::resized() void JucerDocumentEditor::handleResize()
{ {
tabbedComponent.setBounds (getLocalBounds().withTrimmedLeft (12)); tabbedComponent.setBounds (getLocalBounds().withTrimmedLeft (12));
} }
void JucerDocumentEditor::changeListenerCallback (ChangeBroadcaster*) void JucerDocumentEditor::resized()
{
handleResize();
}
void JucerDocumentEditor::handleChange()
{ {
setName (document->getClassName()); setName (document->getClassName());
updateTabs(); updateTabs();
} }
void JucerDocumentEditor::changeListenerCallback (ChangeBroadcaster*)
{
handleChange();
}
//============================================================================== //==============================================================================
ApplicationCommandTarget* JucerDocumentEditor::getNextCommandTarget() ApplicationCommandTarget* JucerDocumentEditor::getNextCommandTarget()
{ {

View file

@ -67,6 +67,9 @@ public:
static JucerDocumentEditor* getActiveDocumentHolder(); static JucerDocumentEditor* getActiveDocumentHolder();
private: private:
void handleResize();
void handleChange();
void changeListenerCallback (ChangeBroadcaster*) override; void changeListenerCallback (ChangeBroadcaster*) override;
std::unique_ptr<JucerDocument> document; std::unique_ptr<JucerDocument> document;

View file

@ -95,7 +95,7 @@ ResourceEditorPanel::ResourceEditorPanel (JucerDocument& doc)
document.addChangeListener (this); document.addChangeListener (this);
handleCommandMessage (1); handleCommandMessage (1);
lookAndFeelChanged(); updateLookAndFeel();
} }
ResourceEditorPanel::~ResourceEditorPanel() ResourceEditorPanel::~ResourceEditorPanel()
@ -180,12 +180,17 @@ int ResourceEditorPanel::getColumnAutoSizeWidth (int columnId)
return widest + 10; return widest + 10;
} }
void ResourceEditorPanel::lookAndFeelChanged() void ResourceEditorPanel::updateLookAndFeel()
{ {
listBox->setColour (ListBox::backgroundColourId, findColour (secondaryBackgroundColourId)); listBox->setColour (ListBox::backgroundColourId, findColour (secondaryBackgroundColourId));
listBox->setColour (ListBox::outlineColourId, Colours::transparentBlack); listBox->setColour (ListBox::outlineColourId, Colours::transparentBlack);
} }
void ResourceEditorPanel::lookAndFeelChanged()
{
updateLookAndFeel();
}
//============================================================================== //==============================================================================
class ResourceSorter class ResourceSorter
{ {

View file

@ -50,6 +50,7 @@ public:
void selectedRowsChanged (int lastRowSelected) override; void selectedRowsChanged (int lastRowSelected) override;
private: private:
void updateLookAndFeel();
void lookAndFeelChanged() override; void lookAndFeelChanged() override;
void reloadAll(); void reloadAll();

View file

@ -120,7 +120,7 @@ void TestComponent::updateContents()
if (loadedDocument != nullptr) if (loadedDocument != nullptr)
{ {
addAndMakeVisible (loadedDocument->createTestComponent (alwaysFillBackground)); addAndMakeVisible (loadedDocument->createTestComponent (alwaysFillBackground));
resized(); handleResize();
} }
} }
@ -155,7 +155,7 @@ void TestComponent::paint (Graphics& g)
} }
} }
void TestComponent::resized() void TestComponent::handleResize()
{ {
if (Component* const c = getChildComponent (0)) if (Component* const c = getChildComponent (0))
{ {
@ -164,6 +164,11 @@ void TestComponent::resized()
} }
} }
void TestComponent::resized()
{
handleResize();
}
//============================================================================== //==============================================================================
void TestComponent::showInDialogBox (JucerDocument& document) void TestComponent::showInDialogBox (JucerDocument& document)
{ {

View file

@ -54,6 +54,8 @@ public:
//============================================================================== //==============================================================================
void paint (Graphics&) override; void paint (Graphics&) override;
void handleResize();
void resized() override; void resized() override;
static void showInDialogBox (JucerDocument&); static void showInDialogBox (JucerDocument&);

View file

@ -48,19 +48,14 @@ void ComponentLayout::changed()
document->changed(); document->changed();
} }
void ComponentLayout::perform (UndoableAction* action, const String& actionName) void ComponentLayout::perform (std::unique_ptr<UndoableAction> action, const String& actionName)
{ {
jassert (document != nullptr); jassert (document != nullptr);
if (document != nullptr) if (document != nullptr)
{ document->getUndoManager().perform (action.release(), actionName);
document->getUndoManager().perform (action, actionName);
}
else else
{
std::unique_ptr<UndoableAction> deleter (action);
action->perform(); action->perform();
}
} }
//============================================================================== //==============================================================================
@ -76,8 +71,8 @@ void ComponentLayout::clearComponents()
class AddCompAction : public UndoableAction class AddCompAction : public UndoableAction
{ {
public: public:
AddCompAction (XmlElement* const xml_, ComponentLayout& layout_) AddCompAction (XmlElement* const xml_, ComponentLayout& layout_, int& index)
: indexAdded (-1), : indexRef (index),
xml (xml_), xml (xml_),
layout (layout_) layout (layout_)
{ {
@ -89,21 +84,21 @@ public:
Component* const newComp = layout.addComponentFromXml (*xml, false); Component* const newComp = layout.addComponentFromXml (*xml, false);
jassert (newComp != nullptr); jassert (newComp != nullptr);
indexAdded = layout.indexOfComponent (newComp); indexRef = layout.indexOfComponent (newComp);
jassert (indexAdded >= 0); jassert (indexRef >= 0);
return indexAdded >= 0; return indexRef >= 0;
} }
bool undo() bool undo()
{ {
showCorrectTab(); showCorrectTab();
layout.removeComponent (layout.getComponent (indexAdded), false); layout.removeComponent (layout.getComponent (indexRef), false);
return true; return true;
} }
int getSizeInUnits() { return 10; } int getSizeInUnits() { return 10; }
int indexAdded; int& indexRef;
private: private:
std::unique_ptr<XmlElement> xml; std::unique_ptr<XmlElement> xml;
@ -164,7 +159,7 @@ void ComponentLayout::removeComponent (Component* comp, const bool undoable)
{ {
if (undoable) if (undoable)
{ {
perform (new DeleteCompAction (comp, *this), "Delete components"); perform (std::make_unique<DeleteCompAction> (comp, *this), "Delete components");
} }
else else
{ {
@ -224,7 +219,7 @@ void ComponentLayout::componentToFront (Component* comp, const bool undoable)
if (comp != nullptr && components.contains (comp)) if (comp != nullptr && components.contains (comp))
{ {
if (undoable) if (undoable)
perform (new FrontBackCompAction (comp, *this, -1), "Move components to front"); perform (std::make_unique<FrontBackCompAction> (comp, *this, -1), "Move components to front");
else else
moveComponentZOrder (components.indexOf (comp), -1); moveComponentZOrder (components.indexOf (comp), -1);
} }
@ -235,7 +230,7 @@ void ComponentLayout::componentToBack (Component* comp, const bool undoable)
if (comp != nullptr && components.contains (comp)) if (comp != nullptr && components.contains (comp))
{ {
if (undoable) if (undoable)
perform (new FrontBackCompAction (comp, *this, 0), "Move components to back"); perform (std::make_unique<FrontBackCompAction> (comp, *this, 0), "Move components to back");
else else
moveComponentZOrder (components.indexOf (comp), 0); moveComponentZOrder (components.indexOf (comp), 0);
} }
@ -432,9 +427,8 @@ Component* ComponentLayout::addComponentFromXml (const XmlElement& xml, const bo
{ {
if (undoable) if (undoable)
{ {
AddCompAction* const action = new AddCompAction (new XmlElement (xml), *this); perform (std::make_unique<AddCompAction> (new XmlElement (xml), *this, addComponentIndexAdded), "Add new components");
perform (action, "Add new components"); return components [addComponentIndexAdded];
return components [action->indexAdded];
} }
if (ComponentTypeHandler* const type if (ComponentTypeHandler* const type
@ -667,7 +661,7 @@ void ComponentLayout::setComponentPosition (Component* comp,
{ {
if (undoable) if (undoable)
{ {
perform (new ChangeCompPositionAction (comp, *this, newPos), "Move components"); perform (std::make_unique<ChangeCompPositionAction> (comp, *this, newPos), "Move components");
} }
else else
{ {
@ -701,7 +695,7 @@ void ComponentLayout::setComponentBoundsAndProperties (Component* componentToPos
{ {
if (undoable) if (undoable)
{ {
perform (new ChangeCompBoundsAndPropertiesAction (componentToPosition, *this, newBounds, props), "Change component bounds"); perform (std::make_unique<ChangeCompBoundsAndPropertiesAction> (componentToPosition, *this, newBounds, props), "Change component bounds");
} }
else else
{ {

View file

@ -118,7 +118,7 @@ public:
void fillInGeneratedCode (GeneratedCode& code) const; void fillInGeneratedCode (GeneratedCode& code) const;
void perform (UndoableAction* action, const String& actionName); void perform (std::unique_ptr<UndoableAction> action, const String& actionName);
void moveComponentZOrder (int oldIndex, int newIndex); void moveComponentZOrder (int oldIndex, int newIndex);
@ -128,6 +128,8 @@ private:
SelectedItemSet <Component*> selected; SelectedItemSet <Component*> selected;
int nextCompUID; int nextCompUID;
int addComponentIndexAdded = 0;
String getUnusedMemberName (String nameRoot, Component* comp) const; String getUnusedMemberName (String nameRoot, Component* comp) const;
}; };

View file

@ -712,9 +712,9 @@ Result Project::loadDocument (const File& file)
return Result::ok(); return Result::ok();
} }
Result Project::saveDocument (const File& file) Result Project::saveDocument ([[maybe_unused]] const File& file)
{ {
jassertquiet (file == getFile()); jassert (file == getFile());
auto sharedResult = Result::ok(); auto sharedResult = Result::ok();
@ -726,9 +726,10 @@ Result Project::saveDocument (const File& file)
return sharedResult; return sharedResult;
} }
void Project::saveDocumentAsync (const File& file, std::function<void (Result)> afterSave) void Project::saveDocumentAsync ([[maybe_unused]] const File& file,
std::function<void (Result)> afterSave)
{ {
jassertquiet (file == getFile()); jassert (file == getFile());
saveProject (Async::yes, nullptr, std::move (afterSave)); saveProject (Async::yes, nullptr, std::move (afterSave));
} }
@ -1263,6 +1264,7 @@ const build_tools::ProjectType& Project::getProjectType() const
auto* guiType = build_tools::ProjectType::findType (build_tools::ProjectType_GUIApp::getTypeName()); auto* guiType = build_tools::ProjectType::findType (build_tools::ProjectType_GUIApp::getTypeName());
jassert (guiType != nullptr); jassert (guiType != nullptr);
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
return *guiType; return *guiType;
} }

View file

@ -65,7 +65,7 @@ public:
CodeBlocksProjectExporter (Project& p, const ValueTree& t, CodeBlocksOS codeBlocksOs) CodeBlocksProjectExporter (Project& p, const ValueTree& t, CodeBlocksOS codeBlocksOs)
: ProjectExporter (p, t), os (codeBlocksOs) : ProjectExporter (p, t), os (codeBlocksOs)
{ {
if (isWindows()) if (isWindowsExporter())
{ {
name = getDisplayNameWindows(); name = getDisplayNameWindows();
targetLocationValue.setDefault (getDefaultBuildsRootFolder() + getTargetFolderNameWindows()); targetLocationValue.setDefault (getDefaultBuildsRootFolder() + getTargetFolderNameWindows());
@ -92,7 +92,7 @@ public:
bool isAndroidStudio() const override { return false; } bool isAndroidStudio() const override { return false; }
bool isAndroid() const override { return false; } bool isAndroid() const override { return false; }
bool isWindows() const override { return os == windowsTarget; } bool isWindows() const override { return isWindowsExporter(); }
bool isLinux() const override { return os == linuxTarget; } bool isLinux() const override { return os == linuxTarget; }
bool isOSX() const override { return false; } bool isOSX() const override { return false; }
bool isiOS() const override { return false; } bool isiOS() const override { return false; }
@ -195,6 +195,7 @@ public:
private: private:
ValueTreePropertyWithDefault targetPlatformValue; ValueTreePropertyWithDefault targetPlatformValue;
bool isWindowsExporter() const { return os == windowsTarget; }
String getTargetPlatformString() const { return targetPlatformValue.get(); } String getTargetPlatformString() const { return targetPlatformValue.get(); }
//============================================================================== //==============================================================================

View file

@ -1918,8 +1918,8 @@ public:
{ {
name = getDisplayName(); name = getDisplayName();
targetPlatformVersion.setDefault (getDefaultWindowsTargetPlatformVersion()); targetPlatformVersion.setDefault (defaultTargetPlatform);
platformToolsetValue.setDefault (getDefaultToolset()); platformToolsetValue.setDefault (defaultToolset);
} }
static String getDisplayName() { return "Visual Studio 2017"; } static String getDisplayName() { return "Visual Studio 2017"; }
@ -1931,8 +1931,8 @@ public:
int getVisualStudioVersion() const override { return 15; } int getVisualStudioVersion() const override { return 15; }
String getSolutionComment() const override { return "# Visual Studio 15"; } String getSolutionComment() const override { return "# Visual Studio 15"; }
String getToolsVersion() const override { return "15.0"; } String getToolsVersion() const override { return "15.0"; }
String getDefaultToolset() const override { return "v141"; } String getDefaultToolset() const override { return defaultToolset; }
String getDefaultWindowsTargetPlatformVersion() const override { return "Latest"; } String getDefaultWindowsTargetPlatformVersion() const override { return defaultTargetPlatform; }
static MSVCProjectExporterVC2017* createForSettings (Project& projectToUse, const ValueTree& settingsToUse) static MSVCProjectExporterVC2017* createForSettings (Project& projectToUse, const ValueTree& settingsToUse)
{ {
@ -1948,6 +1948,9 @@ public:
MSVCProjectExporterBase::createExporterProperties (props); MSVCProjectExporterBase::createExporterProperties (props);
} }
private:
const String defaultToolset { "v141" }, defaultTargetPlatform { "Latest" };
JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2017) JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2017)
}; };
@ -1960,8 +1963,8 @@ public:
{ {
name = getDisplayName(); name = getDisplayName();
targetPlatformVersion.setDefault (getDefaultWindowsTargetPlatformVersion()); targetPlatformVersion.setDefault (defaultTargetPlatform);
platformToolsetValue.setDefault (getDefaultToolset()); platformToolsetValue.setDefault (defaultToolset);
} }
static String getDisplayName() { return "Visual Studio 2019"; } static String getDisplayName() { return "Visual Studio 2019"; }
@ -1973,8 +1976,8 @@ public:
int getVisualStudioVersion() const override { return 16; } int getVisualStudioVersion() const override { return 16; }
String getSolutionComment() const override { return "# Visual Studio Version 16"; } String getSolutionComment() const override { return "# Visual Studio Version 16"; }
String getToolsVersion() const override { return "16.0"; } String getToolsVersion() const override { return "16.0"; }
String getDefaultToolset() const override { return "v142"; } String getDefaultToolset() const override { return defaultToolset; }
String getDefaultWindowsTargetPlatformVersion() const override { return "10.0"; } String getDefaultWindowsTargetPlatformVersion() const override { return defaultTargetPlatform; }
static MSVCProjectExporterVC2019* createForSettings (Project& projectToUse, const ValueTree& settingsToUse) static MSVCProjectExporterVC2019* createForSettings (Project& projectToUse, const ValueTree& settingsToUse)
{ {
@ -1990,6 +1993,9 @@ public:
MSVCProjectExporterBase::createExporterProperties (props); MSVCProjectExporterBase::createExporterProperties (props);
} }
private:
const String defaultToolset { "v142" }, defaultTargetPlatform { "10.0" };
JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2019) JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2019)
}; };
@ -2002,8 +2008,8 @@ public:
{ {
name = getDisplayName(); name = getDisplayName();
targetPlatformVersion.setDefault (getDefaultWindowsTargetPlatformVersion()); targetPlatformVersion.setDefault (defaultTargetPlatform);
platformToolsetValue.setDefault (getDefaultToolset()); platformToolsetValue.setDefault (defaultToolset);
} }
static String getDisplayName() { return "Visual Studio 2022"; } static String getDisplayName() { return "Visual Studio 2022"; }
@ -2015,8 +2021,8 @@ public:
int getVisualStudioVersion() const override { return 17; } int getVisualStudioVersion() const override { return 17; }
String getSolutionComment() const override { return "# Visual Studio Version 17"; } String getSolutionComment() const override { return "# Visual Studio Version 17"; }
String getToolsVersion() const override { return "17.0"; } String getToolsVersion() const override { return "17.0"; }
String getDefaultToolset() const override { return "v143"; } String getDefaultToolset() const override { return defaultToolset; }
String getDefaultWindowsTargetPlatformVersion() const override { return "10.0"; } String getDefaultWindowsTargetPlatformVersion() const override { return defaultTargetPlatform; }
static MSVCProjectExporterVC2022* createForSettings (Project& projectToUse, const ValueTree& settingsToUse) static MSVCProjectExporterVC2022* createForSettings (Project& projectToUse, const ValueTree& settingsToUse)
{ {
@ -2032,5 +2038,8 @@ public:
MSVCProjectExporterBase::createExporterProperties (props); MSVCProjectExporterBase::createExporterProperties (props);
} }
private:
const String defaultToolset { "v143" }, defaultTargetPlatform { "10.0" };
JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2022) JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterVC2022)
}; };

View file

@ -114,7 +114,7 @@ private:
browseButton.onClick = [this] { browse(); }; browseButton.onClick = [this] { browse(); };
addAndMakeVisible (browseButton); addAndMakeVisible (browseButton);
lookAndFeelChanged(); updateLookAndFeel();
} }
void setTo (File f) void setTo (File f)
@ -187,7 +187,7 @@ private:
} }
} }
void lookAndFeelChanged() override void updateLookAndFeel()
{ {
browseButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId)); browseButton.setColour (TextButton::buttonColourId, findColour (secondaryButtonBackgroundColourId));
browseButton.setColour (TextButton::textColourOffId, Colours::white); browseButton.setColour (TextButton::textColourOffId, Colours::white);
@ -195,6 +195,11 @@ private:
updateEditorColour(); updateEditorColour();
} }
void lookAndFeelChanged() override
{
updateLookAndFeel();
}
//============================================================================== //==============================================================================
Value textValue; Value textValue;
@ -232,18 +237,23 @@ public:
value (valueToListenTo.getPropertyAsValue()) value (valueToListenTo.getPropertyAsValue())
{ {
value.addListener (this); value.addListener (this);
valueChanged (value); handleValueChanged (value);
} }
~FilePathPropertyComponentWithEnablement() override { value.removeListener (this); } ~FilePathPropertyComponentWithEnablement() override { value.removeListener (this); }
private: private:
void valueChanged (Value& v) override void handleValueChanged (Value& v)
{ {
FilePathPropertyComponent::valueChanged (v); FilePathPropertyComponent::valueChanged (v);
setEnabled (propertyWithDefault.get()); setEnabled (propertyWithDefault.get());
} }
void valueChanged (Value& v) override
{
handleValueChanged (v);
}
ValueTreePropertyWithDefault propertyWithDefault; ValueTreePropertyWithDefault propertyWithDefault;
Value value; Value value;
}; };

View file

@ -68,7 +68,7 @@ public:
value (valueToListenTo.getPropertyAsValue()) value (valueToListenTo.getPropertyAsValue())
{ {
value.addListener (this); value.addListener (this);
valueChanged (value); handleValueChanged();
} }
ChoicePropertyComponentWithEnablement (const ValueTreePropertyWithDefault& valueToControl, ChoicePropertyComponentWithEnablement (const ValueTreePropertyWithDefault& valueToControl,
@ -84,7 +84,7 @@ public:
isMultiChoice = true; isMultiChoice = true;
idToCheck = multiChoiceID; idToCheck = multiChoiceID;
valueChanged (value); handleValueChanged();
} }
ChoicePropertyComponentWithEnablement (const ValueTreePropertyWithDefault& valueToControl, ChoicePropertyComponentWithEnablement (const ValueTreePropertyWithDefault& valueToControl,
@ -95,7 +95,7 @@ public:
value (valueToListenTo.getPropertyAsValue()) value (valueToListenTo.getPropertyAsValue())
{ {
value.addListener (this); value.addListener (this);
valueChanged (value); handleValueChanged();
} }
~ChoicePropertyComponentWithEnablement() override { value.removeListener (this); } ~ChoicePropertyComponentWithEnablement() override { value.removeListener (this); }
@ -120,13 +120,18 @@ private:
return false; return false;
} }
void valueChanged (Value&) override void handleValueChanged()
{ {
if (isMultiChoice) if (isMultiChoice)
setEnabled (checkMultiChoiceVar()); setEnabled (checkMultiChoiceVar());
else else
setEnabled (propertyWithDefault.get()); setEnabled (propertyWithDefault.get());
} }
void valueChanged (Value&) override
{
handleValueChanged();
}
}; };
//============================================================================== //==============================================================================

View file

@ -55,7 +55,7 @@ int main (int argc, char **argv)
if (args.containsOption ("--help|-h")) if (args.containsOption ("--help|-h"))
{ {
std::cout << argv[0] << " [--help|-h] [--list-categories] [--category category] [--seed seed]" << std::endl; std::cout << argv[0] << " [--help|-h] [--list-categories] [--category=category] [--seed=seed]" << std::endl;
return 0; return 0;
} }

View file

@ -136,6 +136,7 @@ public:
for (int i = 0; i < numSamples; ++i) for (int i = 0; i < numSamples; ++i)
{ {
// NOLINTNEXTLINE(clang-analyzer-core.NullDereference)
const float input = (left[i] + right[i]) * gain; const float input = (left[i] + right[i]) * gain;
float outL = 0, outR = 0; float outL = 0, outR = 0;

View file

@ -642,18 +642,18 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater
Boolean hostIsCycling = NO; Boolean hostIsCycling = NO;
Float64 hostCycleStartBeat = 0; Float64 hostCycleStartBeat = 0;
Float64 hostCycleEndBeat = 0; Float64 hostCycleEndBeat = 0;
OSStatus err = callbackInfo.transportStateProc2 (callbackInfo.hostUserData, auto transportErr = callbackInfo.transportStateProc2 (callbackInfo.hostUserData,
&hostIsPlaying, &hostIsPlaying,
&hostIsRecording, &hostIsRecording,
nullptr, nullptr,
&hostCurrentSampleInTimeLine, &hostCurrentSampleInTimeLine,
&hostIsCycling, &hostIsCycling,
&hostCycleStartBeat, &hostCycleStartBeat,
&hostCycleEndBeat); &hostCycleEndBeat);
if (err == kAUGraphErr_CannotDoInCurrentContext) if (transportErr == kAUGraphErr_CannotDoInCurrentContext)
return {}; return {};
jassert (err == noErr); jassert (transportErr == noErr);
PositionInfo result; PositionInfo result;
@ -666,10 +666,10 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater
Float64 hostBeat = 0; Float64 hostBeat = 0;
Float64 hostTempo = 0; Float64 hostTempo = 0;
err = callbackInfo.beatAndTempoProc (callbackInfo.hostUserData, [[maybe_unused]] auto batErr = callbackInfo.beatAndTempoProc (callbackInfo.hostUserData,
&hostBeat, &hostBeat,
&hostTempo); &hostTempo);
jassert (err == noErr); jassert (batErr == noErr);
result.setPpqPosition (hostBeat); result.setPpqPosition (hostBeat);
result.setBpm (hostTempo); result.setBpm (hostTempo);
@ -677,12 +677,12 @@ struct iOSAudioIODevice::Pimpl : public AsyncUpdater
Float32 hostTimeSigNumerator = 0; Float32 hostTimeSigNumerator = 0;
UInt32 hostTimeSigDenominator = 0; UInt32 hostTimeSigDenominator = 0;
Float64 hostCurrentMeasureDownBeat = 0; Float64 hostCurrentMeasureDownBeat = 0;
err = callbackInfo.musicalTimeLocationProc (callbackInfo.hostUserData, [[maybe_unused]] auto timeErr = callbackInfo.musicalTimeLocationProc (callbackInfo.hostUserData,
nullptr, nullptr,
&hostTimeSigNumerator, &hostTimeSigNumerator,
&hostTimeSigDenominator, &hostTimeSigDenominator,
&hostCurrentMeasureDownBeat); &hostCurrentMeasureDownBeat);
jassert (err == noErr); jassert (timeErr == noErr);
result.setPpqPositionOfLastBarStart (hostCurrentMeasureDownBeat); result.setPpqPositionOfLastBarStart (hostCurrentMeasureDownBeat);
result.setTimeSignature (TimeSignature { (int) hostTimeSigNumerator, (int) hostTimeSigDenominator }); result.setTimeSignature (TimeSignature { (int) hostTimeSigNumerator, (int) hostTimeSigDenominator });

View file

@ -346,8 +346,8 @@ public:
if (client != nullptr) if (client != nullptr)
{ {
const auto result = juce::jack_deactivate (client); [[maybe_unused]] const auto result = juce::jack_deactivate (client);
jassertquiet (result == 0); jassert (result == 0);
juce::jack_set_xrun_callback (client, xrunCallback, nullptr); juce::jack_set_xrun_callback (client, xrunCallback, nullptr);
juce::jack_set_process_callback (client, processCallback, nullptr); juce::jack_set_process_callback (client, processCallback, nullptr);
@ -544,9 +544,9 @@ private:
} }
} }
static void infoShutdownCallback (jack_status_t code, [[maybe_unused]] const char* reason, void* arg) static void infoShutdownCallback ([[maybe_unused]] jack_status_t code, [[maybe_unused]] const char* reason, void* arg)
{ {
jassertquiet (code == 0); jassert (code == 0);
JUCE_JACK_LOG ("Shutting down with message:"); JUCE_JACK_LOG ("Shutting down with message:");
JUCE_JACK_LOG (reason); JUCE_JACK_LOG (reason);

View file

@ -0,0 +1,3 @@
# We want to ignore this directory, but we need to enable at least a single
# check to avoid an error
Checks: -*,darwin-dispatch-once-nonstatic

View file

@ -74,19 +74,19 @@ void ARAAudioSourceReader::willUpdateAudioSourceProperties (ARAAudioSource* audi
} }
} }
void ARAAudioSourceReader::doUpdateAudioSourceContent (ARAAudioSource* audioSource, void ARAAudioSourceReader::doUpdateAudioSourceContent ([[maybe_unused]] ARAAudioSource* audioSource,
ARAContentUpdateScopes scopeFlags) ARAContentUpdateScopes scopeFlags)
{ {
jassertquiet (audioSourceBeingRead == audioSource); jassert (audioSourceBeingRead == audioSource);
// Don't invalidate if the audio signal is unchanged // Don't invalidate if the audio signal is unchanged
if (scopeFlags.affectSamples()) if (scopeFlags.affectSamples())
invalidate(); invalidate();
} }
void ARAAudioSourceReader::willEnableAudioSourceSamplesAccess (ARAAudioSource* audioSource, bool enable) void ARAAudioSourceReader::willEnableAudioSourceSamplesAccess ([[maybe_unused]] ARAAudioSource* audioSource, bool enable)
{ {
jassertquiet (audioSourceBeingRead == audioSource); jassert (audioSourceBeingRead == audioSource);
// Invalidate our reader if sample access is disabled // Invalidate our reader if sample access is disabled
if (! enable) if (! enable)
@ -96,9 +96,9 @@ void ARAAudioSourceReader::willEnableAudioSourceSamplesAccess (ARAAudioSource* a
} }
} }
void ARAAudioSourceReader::didEnableAudioSourceSamplesAccess (ARAAudioSource* audioSource, bool enable) void ARAAudioSourceReader::didEnableAudioSourceSamplesAccess ([[maybe_unused]] ARAAudioSource* audioSource, bool enable)
{ {
jassertquiet (audioSourceBeingRead == audioSource); jassert (audioSourceBeingRead == audioSource);
// Recreate our reader if sample access is enabled // Recreate our reader if sample access is enabled
if (enable && isValid()) if (enable && isValid())
@ -108,9 +108,9 @@ void ARAAudioSourceReader::didEnableAudioSourceSamplesAccess (ARAAudioSource* au
} }
} }
void ARAAudioSourceReader::willDestroyAudioSource (ARAAudioSource* audioSource) void ARAAudioSourceReader::willDestroyAudioSource ([[maybe_unused]] ARAAudioSource* audioSource)
{ {
jassertquiet (audioSourceBeingRead == audioSource); jassert (audioSourceBeingRead == audioSource);
invalidate(); invalidate();
} }
@ -290,19 +290,19 @@ void ARAPlaybackRegionReader::willUpdatePlaybackRegionProperties (ARAPlaybackReg
} }
} }
void ARAPlaybackRegionReader::didUpdatePlaybackRegionContent (ARAPlaybackRegion* playbackRegion, void ARAPlaybackRegionReader::didUpdatePlaybackRegionContent ([[maybe_unused]] ARAPlaybackRegion* playbackRegion,
ARAContentUpdateScopes scopeFlags) ARAContentUpdateScopes scopeFlags)
{ {
jassertquiet (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion)); jassert (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion));
// Invalidate if the audio signal is changed // Invalidate if the audio signal is changed
if (scopeFlags.affectSamples()) if (scopeFlags.affectSamples())
invalidate(); invalidate();
} }
void ARAPlaybackRegionReader::willDestroyPlaybackRegion (ARAPlaybackRegion* playbackRegion) void ARAPlaybackRegionReader::willDestroyPlaybackRegion ([[maybe_unused]] ARAPlaybackRegion* playbackRegion)
{ {
jassertquiet (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion)); jassert (ARA::contains (playbackRenderer->getPlaybackRegions(), playbackRegion));
invalidate(); invalidate();
} }

View file

@ -85,7 +85,7 @@ public:
shouldMuteInput.addListener (this); shouldMuteInput.addListener (this);
shouldMuteInput = ! isInterAppAudioConnected(); shouldMuteInput = ! isInterAppAudioConnected();
createPlugin(); handleCreatePlugin();
auto inChannels = (channelConfiguration.size() > 0 ? channelConfiguration[0].numIns auto inChannels = (channelConfiguration.size() > 0 ? channelConfiguration[0].numIns
: processor->getMainBusNumInputChannels()); : processor->getMainBusNumInputChannels());
@ -117,24 +117,19 @@ public:
{ {
stopTimer(); stopTimer();
deletePlugin(); handleDeletePlugin();
shutDownAudioDevices(); shutDownAudioDevices();
} }
//============================================================================== //==============================================================================
virtual void createPlugin() virtual void createPlugin()
{ {
processor = createPluginFilterOfType (AudioProcessor::wrapperType_Standalone); handleCreatePlugin();
processor->disableNonMainBuses();
processor->setRateAndBufferSizeDetails (44100, 512);
processorHasPotentialFeedbackLoop = (getNumInputChannels() > 0 && getNumOutputChannels() > 0);
} }
virtual void deletePlugin() virtual void deletePlugin()
{ {
stopPlaying(); handleDeletePlugin();
processor = nullptr;
} }
int getNumInputChannels() const int getNumInputChannels() const
@ -428,6 +423,23 @@ public:
ScopedMessageBox messageBox; ScopedMessageBox messageBox;
private: private:
//==============================================================================
void handleCreatePlugin()
{
processor = createPluginFilterOfType (AudioProcessor::wrapperType_Standalone);
processor->disableNonMainBuses();
processor->setRateAndBufferSizeDetails (44100, 512);
processorHasPotentialFeedbackLoop = (getNumInputChannels() > 0 && getNumOutputChannels() > 0);
}
void handleDeletePlugin()
{
stopPlaying();
processor = nullptr;
}
//==============================================================================
/* This class can be used to ensure that audio callbacks use buffers with a /* This class can be used to ensure that audio callbacks use buffers with a
predictable maximum size. predictable maximum size.
@ -457,14 +469,14 @@ private:
} }
void audioDeviceIOCallbackWithContext (const float* const* inputChannelData, void audioDeviceIOCallbackWithContext (const float* const* inputChannelData,
int numInputChannels, [[maybe_unused]] int numInputChannels,
float* const* outputChannelData, float* const* outputChannelData,
int numOutputChannels, [[maybe_unused]] int numOutputChannels,
int numSamples, int numSamples,
const AudioIODeviceCallbackContext& context) override const AudioIODeviceCallbackContext& context) override
{ {
jassertquiet ((int) storedInputChannels.size() == numInputChannels); jassert ((int) storedInputChannels.size() == numInputChannels);
jassertquiet ((int) storedOutputChannels.size() == numOutputChannels); jassert ((int) storedOutputChannels.size() == numOutputChannels);
int position = 0; int position = 0;
@ -901,7 +913,7 @@ private:
if (editor != nullptr) if (editor != nullptr)
{ {
editor->addComponentListener (this); editor->addComponentListener (this);
componentMovedOrResized (*editor, false, true); handleMovedOrResized();
addAndMakeVisible (editor.get()); addAndMakeVisible (editor.get());
} }
@ -929,20 +941,7 @@ private:
void resized() override void resized() override
{ {
auto r = getLocalBounds(); handleResized();
if (shouldShowNotification)
notification.setBounds (r.removeFromTop (NotificationArea::height));
if (editor != nullptr)
{
const auto newPos = r.getTopLeft().toFloat().transformedBy (editor->getTransform().inverted());
if (preventResizingEditor)
editor->setTopLeftPosition (newPos.roundToInt());
else
editor->setBoundsConstrained (editor->getLocalArea (this, r.toFloat()).withPosition (newPos).toNearestInt());
}
} }
ComponentBoundsConstrainer* getEditorConstrainer() const ComponentBoundsConstrainer* getEditorConstrainer() const
@ -1023,7 +1022,7 @@ private:
notification.setVisible (shouldShowNotification); notification.setVisible (shouldShowNotification);
#if JUCE_IOS || JUCE_ANDROID #if JUCE_IOS || JUCE_ANDROID
resized(); handleResized();
#else #else
if (editor != nullptr) if (editor != nullptr)
{ {
@ -1045,7 +1044,25 @@ private:
} }
//============================================================================== //==============================================================================
void componentMovedOrResized (Component&, bool, bool) override void handleResized()
{
auto r = getLocalBounds();
if (shouldShowNotification)
notification.setBounds (r.removeFromTop (NotificationArea::height));
if (editor != nullptr)
{
const auto newPos = r.getTopLeft().toFloat().transformedBy (editor->getTransform().inverted());
if (preventResizingEditor)
editor->setTopLeftPosition (newPos.roundToInt());
else
editor->setBoundsConstrained (editor->getLocalArea (this, r.toFloat()).withPosition (newPos).toNearestInt());
}
}
void handleMovedOrResized()
{ {
const ScopedValueSetter<bool> scope (preventResizingEditor, true); const ScopedValueSetter<bool> scope (preventResizingEditor, true);
@ -1058,6 +1075,11 @@ private:
} }
} }
void componentMovedOrResized (Component&, bool, bool) override
{
handleMovedOrResized();
}
Rectangle<int> getSizeToContainEditor() const Rectangle<int> getSizeToContainEditor() const
{ {
if (editor != nullptr) if (editor != nullptr)

View file

@ -115,9 +115,9 @@ namespace AAXClasses
return result; return result;
} }
static void check (AAX_Result result) static void check ([[maybe_unused]] AAX_Result result)
{ {
jassertquiet (result == AAX_SUCCESS); jassert (result == AAX_SUCCESS);
} }
// maps a channel index of an AAX format to an index of a juce format // maps a channel index of an AAX format to an index of a juce format
@ -1482,8 +1482,8 @@ namespace AAXClasses
AudioProcessor::BusesLayout& fullLayout) AudioProcessor::BusesLayout& fullLayout)
{ {
auto currentLayout = getDefaultLayout (p, true); auto currentLayout = getDefaultLayout (p, true);
bool success = p.checkBusesLayoutSupported (currentLayout); [[maybe_unused]] bool success = p.checkBusesLayoutSupported (currentLayout);
jassertquiet (success); jassert (success);
auto numInputBuses = p.getBusCount (true); auto numInputBuses = p.getBusCount (true);
auto numOutputBuses = p.getBusCount (false); auto numOutputBuses = p.getBusCount (false);
@ -1816,7 +1816,7 @@ namespace AAXClasses
bool getMainBusFormats (AudioChannelSet& inputSet, AudioChannelSet& outputSet) bool getMainBusFormats (AudioChannelSet& inputSet, AudioChannelSet& outputSet)
{ {
auto& audioProcessor = getPluginInstance(); [[maybe_unused]] auto& audioProcessor = getPluginInstance();
#if JucePlugin_IsMidiEffect #if JucePlugin_IsMidiEffect
// MIDI effect plug-ins do not support any audio channels // MIDI effect plug-ins do not support any audio channels
@ -2419,8 +2419,8 @@ namespace AAXClasses
Array<int32>& pluginIds, Array<int32>& pluginIds,
const int numMeters) const int numMeters)
{ {
auto aaxInputFormat = getFormatForAudioChannelSet (fullLayout.getMainInputChannelSet(), false); [[maybe_unused]] auto aaxInputFormat = getFormatForAudioChannelSet (fullLayout.getMainInputChannelSet(), false);
auto aaxOutputFormat = getFormatForAudioChannelSet (fullLayout.getMainOutputChannelSet(), false); [[maybe_unused]] auto aaxOutputFormat = getFormatForAudioChannelSet (fullLayout.getMainOutputChannelSet(), false);
#if JucePlugin_IsSynth #if JucePlugin_IsSynth
if (aaxInputFormat == AAX_eStemFormat_None) if (aaxInputFormat == AAX_eStemFormat_None)
@ -2589,8 +2589,8 @@ namespace AAXClasses
static void getPlugInDescription (AAX_IEffectDescriptor& descriptor, [[maybe_unused]] const AAX_IFeatureInfo* featureInfo) static void getPlugInDescription (AAX_IEffectDescriptor& descriptor, [[maybe_unused]] const AAX_IFeatureInfo* featureInfo)
{ {
auto plugin = createPluginFilterOfType (AudioProcessor::wrapperType_AAX); auto plugin = createPluginFilterOfType (AudioProcessor::wrapperType_AAX);
auto numInputBuses = plugin->getBusCount (true); [[maybe_unused]] auto numInputBuses = plugin->getBusCount (true);
auto numOutputBuses = plugin->getBusCount (false); [[maybe_unused]] auto numOutputBuses = plugin->getBusCount (false);
auto pluginNames = plugin->getAlternateDisplayNames(); auto pluginNames = plugin->getAlternateDisplayNames();

View file

@ -1677,20 +1677,25 @@ public:
{ {
if (detail::PluginUtilities::getHostType().isAbletonLive()) if (detail::PluginUtilities::getHostType().isAbletonLive())
{ {
static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event NSEvent* currentEvent = [NSApp currentEvent];
NSTimeInterval eventTime = [[NSApp currentEvent] timestamp];
if (! approximatelyEqual (lastEventTime, eventTime)) if (currentEvent != nil)
{ {
lastEventTime = eventTime; static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event
NSTimeInterval eventTime = [currentEvent timestamp];
NSView* view = (NSView*) getWindowHandle(); if (! approximatelyEqual (lastEventTime, eventTime))
NSView* hostView = [view superview]; {
NSWindow* hostWindow = [hostView window]; lastEventTime = eventTime;
[hostWindow makeFirstResponder: hostView]; auto* view = (NSView*) getWindowHandle();
[hostView keyDown: (NSEvent*) [NSApp currentEvent]]; auto* hostView = [view superview];
[hostWindow makeFirstResponder: view]; auto* hostWindow = [hostView window];
[hostWindow makeFirstResponder: hostView];
[hostView keyDown: currentEvent];
[hostWindow makeFirstResponder: view];
}
} }
} }

View file

@ -61,7 +61,7 @@ public:
{ {
PropertiesFile::Options options; PropertiesFile::Options options;
options.applicationName = getApplicationName(); options.applicationName = appName;
options.filenameSuffix = ".settings"; options.filenameSuffix = ".settings";
options.osxLibrarySubFolder = "Application Support"; options.osxLibrarySubFolder = "Application Support";
#if JUCE_LINUX || JUCE_BSD #if JUCE_LINUX || JUCE_BSD
@ -73,7 +73,7 @@ public:
appProperties.setStorageParameters (options); appProperties.setStorageParameters (options);
} }
const String getApplicationName() override { return CharPointer_UTF8 (JucePlugin_Name); } const String getApplicationName() override { return appName; }
const String getApplicationVersion() override { return JucePlugin_VersionString; } const String getApplicationVersion() override { return JucePlugin_VersionString; }
bool moreThanOneInstanceAllowed() override { return true; } bool moreThanOneInstanceAllowed() override { return true; }
void anotherInstanceStarted (const String&) override {} void anotherInstanceStarted (const String&) override {}
@ -140,6 +140,9 @@ public:
protected: protected:
ApplicationProperties appProperties; ApplicationProperties appProperties;
std::unique_ptr<StandaloneFilterWindow> mainWindow; std::unique_ptr<StandaloneFilterWindow> mainWindow;
private:
const String appName { CharPointer_UTF8 (JucePlugin_Name) };
}; };
} // namespace juce } // namespace juce

View file

@ -327,9 +327,9 @@ public:
#ifdef JucePlugin_PreferredChannelConfigurations #ifdef JucePlugin_PreferredChannelConfigurations
short configs[][2] = { JucePlugin_PreferredChannelConfigurations }; short configs[][2] = { JucePlugin_PreferredChannelConfigurations };
const int numConfigs = sizeof (configs) / sizeof (short[2]); [[maybe_unused]] const int numConfigs = sizeof (configs) / sizeof (short[2]);
jassertquiet (numConfigs > 0 && (configs[0][0] > 0 || configs[0][1] > 0)); jassert (numConfigs > 0 && (configs[0][0] > 0 || configs[0][1] > 0));
pluginInstance->setPlayConfigDetails (configs[0][0], configs[0][1], state->sampleRate, samplesPerBlock); pluginInstance->setPlayConfigDetails (configs[0][0], configs[0][1], state->sampleRate, samplesPerBlock);
#else #else

View file

@ -1943,8 +1943,11 @@ private:
*pluginInput = cachedInArrangement. getData(); *pluginInput = cachedInArrangement. getData();
*pluginOutput = cachedOutArrangement.getData(); *pluginOutput = cachedOutArrangement.getData();
SpeakerMappings::channelSetToVstArrangement (processor->getChannelLayoutOfBus (true, 0), **pluginInput); if (*pluginInput != nullptr)
SpeakerMappings::channelSetToVstArrangement (processor->getChannelLayoutOfBus (false, 0), **pluginOutput); SpeakerMappings::channelSetToVstArrangement (processor->getChannelLayoutOfBus (true, 0), **pluginInput);
if (*pluginOutput != nullptr)
SpeakerMappings::channelSetToVstArrangement (processor->getChannelLayoutOfBus (false, 0), **pluginOutput);
return 1; return 1;
} }

View file

@ -51,6 +51,7 @@ CPluginView::CPluginView (const ViewRect* _rect)
//------------------------------------------------------------------------ //------------------------------------------------------------------------
CPluginView::~CPluginView () CPluginView::~CPluginView ()
{ {
// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall)
setFrame (nullptr); setFrame (nullptr);
} }

View file

@ -1001,12 +1001,11 @@ public:
if (getElementCount (scope) != n && isBusCountWritable (isInput)) if (getElementCount (scope) != n && isBusCountWritable (isInput))
{ {
OSStatus err;
auto newCount = static_cast<UInt32> (n); auto newCount = static_cast<UInt32> (n);
layoutHasChanged = true; layoutHasChanged = true;
err = AudioUnitSetProperty (audioUnit, kAudioUnitProperty_ElementCount, scope, 0, &newCount, sizeof (newCount)); [[maybe_unused]] auto err = AudioUnitSetProperty (audioUnit, kAudioUnitProperty_ElementCount, scope, 0, &newCount, sizeof (newCount));
jassertquiet (err == noErr); jassert (err == noErr);
} }
for (int i = 0; i < n; ++i) for (int i = 0; i < n; ++i)

View file

@ -739,10 +739,11 @@ public:
LV2_Log_Log* getLogFeature() { return &logFeature; } LV2_Log_Log* getLogFeature() { return &logFeature; }
private: private:
int vprintfCallback (LV2_URID type, const char* fmt, va_list ap) const int vprintfCallback ([[maybe_unused]] LV2_URID type, const char* fmt, va_list ap) const
{ {
// If this is hit, the plugin has encountered some kind of error // If this is hit, the plugin has encountered some kind of error
jassertquiet (type != urids->mLV2_LOG__Error && type != urids->mLV2_LOG__Warning); ignoreUnused (urids);
jassert (type != urids->mLV2_LOG__Error && type != urids->mLV2_LOG__Warning);
return std::vfprintf (stderr, fmt, ap); return std::vfprintf (stderr, fmt, ap);
} }
@ -2118,9 +2119,9 @@ public:
private: private:
template <typename Value> template <typename Value>
static float getValueFrom (const void* data, uint32_t size) static float getValueFrom (const void* data, [[maybe_unused]] uint32_t size)
{ {
jassertquiet (size == sizeof (Value)); jassert (size == sizeof (Value));
return (float) readUnaligned<Value> (data); return (float) readUnaligned<Value> (data);
} }

View file

@ -1166,6 +1166,8 @@ private:
}; };
//============================================================================== //==============================================================================
// We have to trust that Steinberg won't double-delete
// NOLINTBEGIN(clang-analyzer-cplusplus.NewDelete)
template <class ObjectType> template <class ObjectType>
class VSTComSmartPtr class VSTComSmartPtr
{ {
@ -1208,6 +1210,7 @@ public:
private: private:
ObjectType* source; ObjectType* source;
}; };
// NOLINTEND(clang-analyzer-cplusplus.NewDelete)
//============================================================================== //==============================================================================
/* This class stores a plugin's preferred MIDI mappings. /* This class stores a plugin's preferred MIDI mappings.

View file

@ -448,7 +448,7 @@ void AudioProcessor::checkForDuplicateTrimmedParamID ([[maybe_unused]] AudioProc
#if JUCE_DEBUG && ! JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING #if JUCE_DEBUG && ! JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING
if (auto* withID = dynamic_cast<HostedAudioProcessorParameter*> (param)) if (auto* withID = dynamic_cast<HostedAudioProcessorParameter*> (param))
{ {
constexpr auto maximumSafeAAXParameterIdLength = 31; [[maybe_unused]] constexpr auto maximumSafeAAXParameterIdLength = 31;
const auto paramID = withID->getParameterID(); const auto paramID = withID->getParameterID();
@ -459,7 +459,7 @@ void AudioProcessor::checkForDuplicateTrimmedParamID ([[maybe_unused]] AudioProc
// If you need to retain backwards-compatibility and are unable to change // If you need to retain backwards-compatibility and are unable to change
// the paramID for this reason, you can add JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING // the paramID for this reason, you can add JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING
// to your preprocessor definitions to silence this assertion. // to your preprocessor definitions to silence this assertion.
jassertquiet (paramID.length() <= maximumSafeAAXParameterIdLength); jassert (paramID.length() <= maximumSafeAAXParameterIdLength);
// If you hit this assertion, two or more parameters have duplicate paramIDs // If you hit this assertion, two or more parameters have duplicate paramIDs
// after they have been truncated to support the AAX format. // after they have been truncated to support the AAX format.
@ -470,7 +470,7 @@ void AudioProcessor::checkForDuplicateTrimmedParamID ([[maybe_unused]] AudioProc
// If you need to retain backwards-compatibility and are unable to change // If you need to retain backwards-compatibility and are unable to change
// the paramID for this reason, you can add JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING // the paramID for this reason, you can add JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING
// to your preprocessor definitions to silence this assertion. // to your preprocessor definitions to silence this assertion.
jassertquiet (trimmedParamIDs.insert (paramID.substring (0, maximumSafeAAXParameterIdLength)).second); jassert (trimmedParamIDs.insert (paramID.substring (0, maximumSafeAAXParameterIdLength)).second);
} }
#endif #endif
} }

View file

@ -567,14 +567,14 @@ private:
} }
} }
void checkSourceIsNotAMember (const ElementType& element) void checkSourceIsNotAMember ([[maybe_unused]] const ElementType& element)
{ {
// when you pass a reference to an existing element into a method like add() which // when you pass a reference to an existing element into a method like add() which
// may need to reallocate the array to make more space, the incoming reference may // may need to reallocate the array to make more space, the incoming reference may
// be deleted indirectly during the reallocation operation! To work around this, // be deleted indirectly during the reallocation operation! To work around this,
// make a local copy of the item you're trying to add (and maybe use std::move to // make a local copy of the item you're trying to add (and maybe use std::move to
// move it into the add() method to avoid any extra overhead) // move it into the add() method to avoid any extra overhead)
jassertquiet (std::addressof (element) < begin() || end() <= std::addressof (element)); jassert (std::addressof (element) < begin() || end() <= std::addressof (element));
} }
//============================================================================== //==============================================================================

View file

@ -134,8 +134,8 @@ public:
static constexpr auto vtableForCallable = detail::makeVtable<Fn, Ret, Args...>(); static constexpr auto vtableForCallable = detail::makeVtable<Fn, Ret, Args...>();
vtable = &vtableForCallable; vtable = &vtableForCallable;
auto* ptr = new (&storage) Fn (std::forward<Callable> (callable)); [[maybe_unused]] auto* ptr = new (&storage) Fn (std::forward<Callable> (callable));
jassertquiet ((void*) ptr == (void*) &storage); jassert ((void*) ptr == (void*) &storage);
} }
/** Move constructor. */ /** Move constructor. */

View file

@ -162,6 +162,8 @@ BigInteger& BigInteger::operator= (const BigInteger& other)
return *this; return *this;
} }
BigInteger::~BigInteger() = default;
uint32* BigInteger::getValues() const noexcept uint32* BigInteger::getValues() const noexcept
{ {
jassert (heapAllocation != nullptr || allocatedSize <= numPreallocatedInts); jassert (heapAllocation != nullptr || allocatedSize <= numPreallocatedInts);

View file

@ -69,7 +69,7 @@ public:
BigInteger& operator= (BigInteger&&) noexcept; BigInteger& operator= (BigInteger&&) noexcept;
/** Destructor. */ /** Destructor. */
~BigInteger() = default; ~BigInteger();
//============================================================================== //==============================================================================
/** Copies another BigInteger onto this one. */ /** Copies another BigInteger onto this one. */

View file

@ -109,9 +109,8 @@ public:
*/ */
template <typename SizeType, std::enable_if_t<std::is_convertible_v<SizeType, int>, int> = 0> template <typename SizeType, std::enable_if_t<std::is_convertible_v<SizeType, int>, int> = 0>
explicit HeapBlock (SizeType numElements) explicit HeapBlock (SizeType numElements)
: data (static_cast<ElementType*> (std::malloc (static_cast<size_t> (numElements) * sizeof (ElementType)))) : data (mallocWrapper (static_cast<size_t> (numElements) * sizeof (ElementType)))
{ {
throwOnAllocationFailure();
} }
/** Creates a HeapBlock containing a number of elements. /** Creates a HeapBlock containing a number of elements.
@ -121,11 +120,9 @@ public:
*/ */
template <typename SizeType, std::enable_if_t<std::is_convertible_v<SizeType, int>, int> = 0> template <typename SizeType, std::enable_if_t<std::is_convertible_v<SizeType, int>, int> = 0>
HeapBlock (SizeType numElements, bool initialiseToZero) HeapBlock (SizeType numElements, bool initialiseToZero)
: data (static_cast<ElementType*> (initialiseToZero : data (initialiseToZero ? callocWrapper (static_cast<size_t> (numElements), sizeof (ElementType))
? std::calloc (static_cast<size_t> (numElements), sizeof (ElementType)) : mallocWrapper (static_cast<size_t> (numElements) * sizeof (ElementType)))
: std::malloc (static_cast<size_t> (numElements) * sizeof (ElementType))))
{ {
throwOnAllocationFailure();
} }
/** Destructor. /** Destructor.
@ -252,8 +249,7 @@ public:
void malloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) void malloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType))
{ {
std::free (data); std::free (data);
data = static_cast<ElementType*> (std::malloc (static_cast<size_t> (newNumElements) * elementSize)); data = mallocWrapper (static_cast<size_t> (newNumElements) * elementSize);
throwOnAllocationFailure();
} }
/** Allocates a specified amount of memory and clears it. /** Allocates a specified amount of memory and clears it.
@ -263,8 +259,7 @@ public:
void calloc (SizeType newNumElements, const size_t elementSize = sizeof (ElementType)) void calloc (SizeType newNumElements, const size_t elementSize = sizeof (ElementType))
{ {
std::free (data); std::free (data);
data = static_cast<ElementType*> (std::calloc (static_cast<size_t> (newNumElements), elementSize)); data = callocWrapper (static_cast<size_t> (newNumElements), elementSize);
throwOnAllocationFailure();
} }
/** Allocates a specified amount of memory and optionally clears it. /** Allocates a specified amount of memory and optionally clears it.
@ -275,10 +270,8 @@ public:
void allocate (SizeType newNumElements, bool initialiseToZero) void allocate (SizeType newNumElements, bool initialiseToZero)
{ {
std::free (data); std::free (data);
data = static_cast<ElementType*> (initialiseToZero data = initialiseToZero ? callocWrapper (static_cast<size_t> (newNumElements), sizeof (ElementType))
? std::calloc (static_cast<size_t> (newNumElements), sizeof (ElementType)) : mallocWrapper (static_cast<size_t> (newNumElements) * sizeof (ElementType));
: std::malloc (static_cast<size_t> (newNumElements) * sizeof (ElementType)));
throwOnAllocationFailure();
} }
/** Re-allocates a specified amount of memory. /** Re-allocates a specified amount of memory.
@ -289,9 +282,7 @@ public:
template <typename SizeType> template <typename SizeType>
void realloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType)) void realloc (SizeType newNumElements, size_t elementSize = sizeof (ElementType))
{ {
data = static_cast<ElementType*> (data == nullptr ? std::malloc (static_cast<size_t> (newNumElements) * elementSize) data = reallocWrapper (data, static_cast<size_t> (newNumElements) * elementSize);
: std::realloc (data, static_cast<size_t> (newNumElements) * elementSize));
throwOnAllocationFailure();
} }
/** Frees any currently-allocated data. /** Frees any currently-allocated data.
@ -327,20 +318,46 @@ public:
private: private:
//============================================================================== //==============================================================================
ElementType* data = nullptr; // Calls to malloc, calloc and realloc with zero size have implementation-defined
// behaviour where either nullptr or a non-null pointer is returned.
void throwOnAllocationFailure() const template <typename Functor>
static ElementType* wrapper (size_t size, Functor&& f)
{ {
if (size == 0)
return nullptr;
auto* memory = static_cast<ElementType*> (f());
#if JUCE_EXCEPTIONS_DISABLED #if JUCE_EXCEPTIONS_DISABLED
jassert (data != nullptr); // without exceptions, you'll need to find a better way to handle this failure case. jassert (memory != nullptr); // without exceptions, you'll need to find a better way to handle this failure case.
#else #else
HeapBlockHelper::ThrowOnFail<throwOnFailure>::checkPointer (data); HeapBlockHelper::ThrowOnFail<throwOnFailure>::checkPointer (memory);
#endif #endif
return memory;
}
static ElementType* mallocWrapper (size_t size)
{
return wrapper (size, [size] { return std::malloc (size); });
}
static ElementType* callocWrapper (size_t num, size_t size)
{
return wrapper (num * size, [num, size] { return std::calloc (num, size); });
}
static ElementType* reallocWrapper (void* ptr, size_t newSize)
{
return wrapper (newSize, [ptr, newSize] { return std::realloc (ptr, newSize); });
} }
template <class OtherElementType, bool otherThrowOnFailure> template <class OtherElementType, bool otherThrowOnFailure>
friend class HeapBlock; friend class HeapBlock;
//==============================================================================
ElementType* data = nullptr;
#if ! (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD)) #if ! (defined (JUCE_DLL) || defined (JUCE_DLL_BUILD))
JUCE_DECLARE_NON_COPYABLE (HeapBlock) JUCE_DECLARE_NON_COPYABLE (HeapBlock)
JUCE_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point! JUCE_PREVENT_HEAP_ALLOCATION // Creating a 'new HeapBlock' would be missing the point!

View file

@ -75,8 +75,6 @@ public:
beginTest ("operators work as expected"); beginTest ("operators work as expected");
{ {
e = {};
e = TestEnum::one; e = TestEnum::one;
expect ((e & TestEnum::one) != TestEnum{}); expect ((e & TestEnum::one) != TestEnum{});
e |= TestEnum::other; e |= TestEnum::other;

View file

@ -46,17 +46,22 @@ inline String nsStringToJuce (NSString* s)
inline NSString* juceStringToNS (const String& s) inline NSString* juceStringToNS (const String& s)
{ {
return [NSString stringWithUTF8String: s.toUTF8()]; // This cast helps linters determine nullability
return (NSString* _Nonnull) [NSString stringWithUTF8String: s.toUTF8()];
} }
inline NSString* nsStringLiteral (const char* const s) noexcept inline NSString* nsStringLiteral (const char* const s) noexcept
{ {
return [NSString stringWithUTF8String: s]; jassert (s != nullptr);
// This cast helps linters determine nullability
return (NSString* _Nonnull) [NSString stringWithUTF8String: s];
} }
inline NSString* nsEmptyString() noexcept inline NSString* nsEmptyString() noexcept
{ {
return [NSString string]; // This cast helps linters determine nullability
return (NSString* _Nonnull) [NSString string];
} }
inline NSURL* createNSURLFromFile (const String& f) inline NSURL* createNSURLFromFile (const String& f)
@ -359,6 +364,8 @@ struct ObjCClass
ObjCClass (const char* nameRoot) ObjCClass (const char* nameRoot)
: cls (objc_allocateClassPair ([SuperclassType class], getRandomisedName (nameRoot).toUTF8(), 0)) : cls (objc_allocateClassPair ([SuperclassType class], getRandomisedName (nameRoot).toUTF8(), 0))
{ {
// The class could not be created. Is the name already in use?
jassert (cls != nil);
} }
~ObjCClass() ~ObjCClass()
@ -371,7 +378,8 @@ struct ObjCClass
void registerClass() void registerClass()
{ {
objc_registerClassPair (cls); if (cls != nil)
objc_registerClassPair (cls);
} }
SuperclassType* createInstance() const SuperclassType* createInstance() const
@ -393,8 +401,8 @@ struct ObjCClass
void addMethod (SEL selector, Result (*callbackFn) (id, SEL, Args...)) void addMethod (SEL selector, Result (*callbackFn) (id, SEL, Args...))
{ {
const auto s = detail::makeCompileTimeStr (@encode (Result), @encode (id), @encode (SEL), @encode (Args)...); const auto s = detail::makeCompileTimeStr (@encode (Result), @encode (id), @encode (SEL), @encode (Args)...);
const auto b = class_addMethod (cls, selector, (IMP) callbackFn, s.data()); [[maybe_unused]] const auto b = class_addMethod (cls, selector, (IMP) callbackFn, s.data());
jassertquiet (b); jassert (b);
} }
void addProtocol (Protocol* protocol) void addProtocol (Protocol* protocol)

View file

@ -163,9 +163,7 @@ namespace juce
/** Platform-independent assertion macro which suppresses ignored-variable /** Platform-independent assertion macro which suppresses ignored-variable
warnings in all build modes. You should probably use a plain jassert() warnings in all build modes. You should probably use a plain jassert()
by default, and only replace it with jassertquiet() once you've and [[maybe_unused]] by default.
convinced yourself that any unused-variable warnings emitted by the
compiler are harmless.
*/ */
#define jassertquiet(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;) #define jassertquiet(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)

View file

@ -108,8 +108,8 @@ bool Base64::convertFromBase64 (OutputStream& binaryOutput, StringRef base64Text
String Base64::toBase64 (const void* sourceData, size_t sourceDataSize) String Base64::toBase64 (const void* sourceData, size_t sourceDataSize)
{ {
MemoryOutputStream m ((sourceDataSize * 4) / 3 + 3); MemoryOutputStream m ((sourceDataSize * 4) / 3 + 3);
bool ok = convertToBase64 (m, sourceData, sourceDataSize); [[maybe_unused]] bool ok = convertToBase64 (m, sourceData, sourceDataSize);
jassertquiet (ok); // should always succeed for this simple case jassert (ok); // should always succeed for this simple case
return m.toString(); return m.toString();
} }

View file

@ -76,11 +76,11 @@ namespace FIR
//============================================================================== //==============================================================================
/** Prepare this filter for processing. */ /** Prepare this filter for processing. */
inline void prepare (const ProcessSpec& spec) noexcept inline void prepare ([[maybe_unused]] const ProcessSpec& spec) noexcept
{ {
// This class can only process mono signals. Use the ProcessorDuplicator class // This class can only process mono signals. Use the ProcessorDuplicator class
// to apply this filter on a multi-channel audio stream. // to apply this filter on a multi-channel audio stream.
jassertquiet (spec.numChannels == 1); jassert (spec.numChannels == 1);
reset(); reset();
} }

View file

@ -82,9 +82,9 @@ public:
const auto numInputChannels = inputBlock.getNumChannels(); const auto numInputChannels = inputBlock.getNumChannels();
const auto numOutputChannels = outputBlock.getNumChannels(); const auto numOutputChannels = outputBlock.getNumChannels();
const auto numSamples = outputBlock.getNumSamples(); [[maybe_unused]] const auto numSamples = outputBlock.getNumSamples();
jassertquiet (inputBlock.getNumSamples() == numSamples); jassert (inputBlock.getNumSamples() == numSamples);
if (numOutputChannels != 2 || numInputChannels == 0 || numInputChannels > 2) if (numOutputChannels != 2 || numInputChannels == 0 || numInputChannels > 2)
return; return;

View file

@ -29,8 +29,8 @@ class InternalMessageQueue
public: public:
InternalMessageQueue() InternalMessageQueue()
{ {
auto err = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, msgpipe); [[maybe_unused]] auto err = ::socketpair (AF_LOCAL, SOCK_STREAM, 0, msgpipe);
jassertquiet (err == 0); jassert (err == 0);
LinuxEventLoop::registerFdCallback (getReadHandle(), LinuxEventLoop::registerFdCallback (getReadHandle(),
[this] (int fd) [this] (int fd)

View file

@ -134,10 +134,10 @@ namespace
#if JUCE_DEBUG #if JUCE_DEBUG
const int maxVal = 0x3fffffff; const int maxVal = 0x3fffffff;
jassertquiet ((int) x >= -maxVal && (int) x <= maxVal jassert ((int) x >= -maxVal && (int) x <= maxVal
&& (int) y >= -maxVal && (int) y <= maxVal && (int) y >= -maxVal && (int) y <= maxVal
&& (int) w >= 0 && (int) w <= maxVal && (int) w >= 0 && (int) w <= maxVal
&& (int) h >= 0 && (int) h <= maxVal); && (int) h >= 0 && (int) h <= maxVal);
#endif #endif
return { x, y, w, h }; return { x, y, w, h };

View file

@ -53,8 +53,8 @@ namespace
{ {
jassert (family != nullptr); jassert (family != nullptr);
ComSmartPtr<IDWriteLocalizedStrings> familyNames; ComSmartPtr<IDWriteLocalizedStrings> familyNames;
auto hr = family->GetFamilyNames (familyNames.resetAndGetPointerAddress()); [[maybe_unused]] auto hr = family->GetFamilyNames (familyNames.resetAndGetPointerAddress());
jassertquiet (SUCCEEDED (hr)); jassert (SUCCEEDED (hr));
return getLocalisedName (familyNames); return getLocalisedName (familyNames);
} }
@ -62,8 +62,8 @@ namespace
{ {
jassert (font != nullptr); jassert (font != nullptr);
ComSmartPtr<IDWriteLocalizedStrings> faceNames; ComSmartPtr<IDWriteLocalizedStrings> faceNames;
auto hr = font->GetFaceNames (faceNames.resetAndGetPointerAddress()); [[maybe_unused]] auto hr = font->GetFaceNames (faceNames.resetAndGetPointerAddress());
jassertquiet (SUCCEEDED (hr)); jassert (SUCCEEDED (hr));
return getLocalisedName (faceNames); return getLocalisedName (faceNames);
} }

View file

@ -150,8 +150,12 @@ std::unique_ptr<ScopedContentSharerInterface> ScopedContentSharerInterface::shar
result.add (URL (tempFile)); result.add (URL (tempFile));
} }
for (const auto& url : result) jassert (std::all_of (result.begin(),
jassertquiet (url.isLocalFile() && url.getLocalFile().existsAsFile()); result.end(),
[] (const auto& url)
{
return url.isLocalFile() && url.getLocalFile().existsAsFile();
}));
return { std::move (result), String{} }; return { std::move (result), String{} };
} }

View file

@ -246,9 +246,9 @@ struct SpVoiceWrapper : public DeletedAtShutdown
{ {
SpVoiceWrapper() SpVoiceWrapper()
{ {
auto hr = voice.CoCreateInstance (ComTypes::CLSID_SpVoice); [[maybe_unused]] auto hr = voice.CoCreateInstance (ComTypes::CLSID_SpVoice);
jassertquiet (SUCCEEDED (hr)); jassert (SUCCEEDED (hr));
} }
~SpVoiceWrapper() override ~SpVoiceWrapper() override

View file

@ -107,9 +107,9 @@ public:
link ([display = displayId] link ([display = displayId]
{ {
CVDisplayLinkRef ptr = nullptr; CVDisplayLinkRef ptr = nullptr;
const auto result = CVDisplayLinkCreateWithCGDisplay (display, &ptr); [[maybe_unused]] const auto result = CVDisplayLinkCreateWithCGDisplay (display, &ptr);
jassertquiet (result == kCVReturnSuccess); jassert (result == kCVReturnSuccess);
jassertquiet (ptr != nullptr); jassert (ptr != nullptr);
return ptr; return ptr;
}()), }()),
onCallback (std::move (onCallbackIn)) onCallback (std::move (onCallbackIn))
@ -125,11 +125,11 @@ public:
return kCVReturnSuccess; return kCVReturnSuccess;
}; };
const auto callbackResult = CVDisplayLinkSetOutputCallback (link.get(), callback, this); [[maybe_unused]] const auto callbackResult = CVDisplayLinkSetOutputCallback (link.get(), callback, this);
jassertquiet (callbackResult == kCVReturnSuccess); jassert (callbackResult == kCVReturnSuccess);
const auto startResult = CVDisplayLinkStart (link.get()); [[maybe_unused]] const auto startResult = CVDisplayLinkStart (link.get());
jassertquiet (startResult == kCVReturnSuccess); jassert (startResult == kCVReturnSuccess);
} }
~ScopedDisplayLink() noexcept ~ScopedDisplayLink() noexcept

View file

@ -136,13 +136,13 @@ ChoicePropertyComponent::ChoicePropertyComponent (const String& name)
ChoicePropertyComponent::ChoicePropertyComponent (const String& name, ChoicePropertyComponent::ChoicePropertyComponent (const String& name,
const StringArray& choiceList, const StringArray& choiceList,
const Array<var>& correspondingValues) [[maybe_unused]] const Array<var>& correspondingValues)
: PropertyComponent (name), : PropertyComponent (name),
choices (choiceList) choices (choiceList)
{ {
// The array of corresponding values must contain one value for each of the items in // The array of corresponding values must contain one value for each of the items in
// the choices array! // the choices array!
jassertquiet (correspondingValues.size() == choices.size()); jassert (correspondingValues.size() == choices.size());
} }
ChoicePropertyComponent::ChoicePropertyComponent (const Value& valueToControl, ChoicePropertyComponent::ChoicePropertyComponent (const Value& valueToControl,

View file

@ -209,12 +209,12 @@ int MultiChoicePropertyComponent::getTotalButtonsHeight (int numButtons)
MultiChoicePropertyComponent::MultiChoicePropertyComponent (const String& propertyName, MultiChoicePropertyComponent::MultiChoicePropertyComponent (const String& propertyName,
const StringArray& choices, const StringArray& choices,
const Array<var>& correspondingValues) [[maybe_unused]] const Array<var>& correspondingValues)
: PropertyComponent (propertyName, jmin (getTotalButtonsHeight (choices.size()), collapsedHeight)) : PropertyComponent (propertyName, jmin (getTotalButtonsHeight (choices.size()), collapsedHeight))
{ {
// The array of corresponding values must contain one value for each of the items in // The array of corresponding values must contain one value for each of the items in
// the choices array! // the choices array!
jassertquiet (choices.size() == correspondingValues.size()); jassert (choices.size() == correspondingValues.size());
for (auto choice : choices) for (auto choice : choices)
addAndMakeVisible (choiceButtons.add (new ToggleButton (choice))); addAndMakeVisible (choiceButtons.add (new ToggleButton (choice)));

View file

@ -504,11 +504,11 @@ void Label::textEditorReturnKeyPressed (TextEditor& ed)
} }
} }
void Label::textEditorEscapeKeyPressed (TextEditor& ed) void Label::textEditorEscapeKeyPressed ([[maybe_unused]] TextEditor& ed)
{ {
if (editor != nullptr) if (editor != nullptr)
{ {
jassertquiet (&ed == editor.get()); jassert (&ed == editor.get());
editor->setText (textValue.toString(), false); editor->setText (textValue.toString(), false);
hideEditor (true); hideEditor (true);

View file

@ -75,10 +75,10 @@ public:
const auto shouldUseES3 = version != defaultGLVersion const auto shouldUseES3 = version != defaultGLVersion
&& [[UIDevice currentDevice].systemVersion floatValue] >= 7.0; && [[UIDevice currentDevice].systemVersion floatValue] >= 7.0;
const auto gotContext = (shouldUseES3 && createContext (kEAGLRenderingAPIOpenGLES3, contextToShare)) [[maybe_unused]] const auto gotContext = (shouldUseES3 && createContext (kEAGLRenderingAPIOpenGLES3, contextToShare))
|| createContext (kEAGLRenderingAPIOpenGLES2, contextToShare); || createContext (kEAGLRenderingAPIOpenGLES2, contextToShare);
jassertquiet (gotContext); jassert (gotContext);
if (context != nil) if (context != nil)
{ {

View file

@ -634,7 +634,7 @@ public:
// The advantage of this callback is that it will catch *all* errors, even if we // The advantage of this callback is that it will catch *all* errors, even if we
// forget to check manually. // forget to check manually.
DBG ("OpenGL DBG message: " << message); DBG ("OpenGL DBG message: " << message);
jassertquiet (type != GL_DEBUG_TYPE_ERROR && severity != GL_DEBUG_SEVERITY_HIGH); jassert (type != GL_DEBUG_TYPE_ERROR && severity != GL_DEBUG_SEVERITY_HIGH);
}, nullptr); }, nullptr);
} }
#endif #endif

View file

@ -52,19 +52,19 @@ struct CameraDevice::Pimpl
} }
[AVCaptureDevice requestAccessForMediaType: AVMediaTypeVideo [AVCaptureDevice requestAccessForMediaType: AVMediaTypeVideo
completionHandler: ^(BOOL granted) completionHandler: ^([[maybe_unused]] BOOL granted)
{ {
// Access to video is required for camera to work, // Access to video is required for camera to work,
// black images will be produced otherwise! // black images will be produced otherwise!
jassertquiet (granted); jassert (granted);
}]; }];
[AVCaptureDevice requestAccessForMediaType: AVMediaTypeAudio [AVCaptureDevice requestAccessForMediaType: AVMediaTypeAudio
completionHandler: ^(BOOL granted) completionHandler: ^([[maybe_unused]] BOOL granted)
{ {
// Access to audio is required for camera to work, // Access to audio is required for camera to work,
// silence will be produced otherwise! // silence will be produced otherwise!
jassertquiet (granted); jassert (granted);
}]; }];
captureSession.startSessionForDeviceWithId (cameraId); captureSession.startSessionForDeviceWithId (cameraId);

View file

@ -379,7 +379,7 @@ private:
{ {
NSError* error = nil; NSError* error = nil;
int successCount = 0; [[maybe_unused]] int successCount = 0;
for (NSString* key : assetKeys.get()) for (NSString* key : assetKeys.get())
{ {
@ -409,7 +409,7 @@ private:
} }
} }
jassertquiet (successCount == (int) [assetKeys.get() count]); jassert (successCount == (int) [assetKeys.get() count]);
preparePlayerItem(); preparePlayerItem();
} }