From f66dbeb8759f19b1a70cef226114d2f85a5f927b Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Thu, 13 Feb 2025 23:26:31 +0100 Subject: [PATCH] Fix more gcc compiler warnings --- Source/Dialogs/MainMenu.h | 2 +- Source/Dialogs/ThemeSettingsPanel.h | 2 +- Source/Objects/FloatAtomObject.h | 2 +- Source/Objects/IEMHelper.h | 18 ++++++++---------- Source/Objects/ScalarObject.h | 2 +- Source/Sidebar/CommandInput.h | 2 +- Source/TabComponent.cpp | 2 +- Source/Utility/CircularBuffer.h | 2 +- Source/Utility/ValueTreeViewer.h | 2 +- 9 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Source/Dialogs/MainMenu.h b/Source/Dialogs/MainMenu.h index c01f379e1..de376937b 100644 --- a/Source/Dialogs/MainMenu.h +++ b/Source/Dialogs/MainMenu.h @@ -41,7 +41,7 @@ class MainMenu : public PopupMenu { }); } - if (auto const isActive = menuItems[2]->isActive = recentlyOpenedTree.getNumChildren() > 0) { + if ((menuItems[2]->isActive = recentlyOpenedTree.getNumChildren() > 0)) { recentlyOpened->addSeparator(); recentlyOpened->addItem("Clear recently opened", [recentlyOpenedTree, editor]() mutable { recentlyOpenedTree.removeAllChildren(nullptr); diff --git a/Source/Dialogs/ThemeSettingsPanel.h b/Source/Dialogs/ThemeSettingsPanel.h index c40bf0eb8..6c7688190 100644 --- a/Source/Dialogs/ThemeSettingsPanel.h +++ b/Source/Dialogs/ThemeSettingsPanel.h @@ -550,7 +550,7 @@ class ThemeSettingsPanel final : public SettingsDialogPanel PlugDataLook::setDefaultFont(fontValue.toString()); SettingsFile::getInstance()->setProperty("default_font", fontValue.getValue()); - if (auto const changed = previousFontName != Fonts::getCurrentFont().toString()) + if (previousFontName != Fonts::getCurrentFont().toString()) pd->updateAllEditorsLNF(); CachedStringWidth<14>::clearCache(); diff --git a/Source/Objects/FloatAtomObject.h b/Source/Objects/FloatAtomObject.h index cf4471a86..b2f6ee91b 100644 --- a/Source/Objects/FloatAtomObject.h +++ b/Source/Objects/FloatAtomObject.h @@ -185,7 +185,7 @@ class FloatAtomObject final : public ObjectBase { g.setColour(outlineColour); g.drawRoundedRectangle(getLocalBounds().toFloat().reduced(0.5f), Corners::objectCornerRadius, 1.0f); - if (bool const highlighed = hasKeyboardFocus(true) && ::getValue(object->locked)) { + if (hasKeyboardFocus(true) && ::getValue(object->locked)) { g.setColour(cnv->editor->getLookAndFeel().findColour(PlugDataColour::objectSelectedOutlineColourId)); g.drawRoundedRectangle(getLocalBounds().toFloat().reduced(1.0f), Corners::objectCornerRadius, 2.0f); } diff --git a/Source/Objects/IEMHelper.h b/Source/Objects/IEMHelper.h index 5911789ab..e175da719 100644 --- a/Source/Objects/IEMHelper.h +++ b/Source/Objects/IEMHelper.h @@ -128,7 +128,7 @@ class IEMHelper { iemcolor = iemgui_color_hex[iemcolor]; } else - iemcolor = -1 - iemcolor & 0xffffff; + iemcolor = (-1 - iemcolor) & 0xffffff; auto const colour = convertFromIEMColour(iemcolor); gui->setParameterExcludingListener(targetValue, colour.toString()); @@ -328,15 +328,13 @@ class IEMHelper { if (auto iemgui = ptr.get()) { if (iemgui->x_lab) { - if (t_symbol const* sym = canvas_realizedollar(iemgui->x_glist, iemgui->x_lab)) { - auto const labelText = getExpandedLabelText(); - int const fontHeight = getFontHeight(); - int const fontWidth = sys_fontwidth(fontHeight); - int const posx = objectBounds.getX() + iemgui->x_ldx; - int const posy = objectBounds.getY() + iemgui->x_ldy; - int const textWidth = fontHeight > 55 ? Font(fontHeight).getStringWidth(labelText) : fontWidth * (labelText.length() + 1); - return { posx, posy, textWidth, fontHeight + 2 }; - } + auto const labelText = getExpandedLabelText(); + int const fontHeight = getFontHeight(); + int const fontWidth = sys_fontwidth(fontHeight); + int const posx = objectBounds.getX() + iemgui->x_ldx; + int const posy = objectBounds.getY() + iemgui->x_ldy; + int const textWidth = fontHeight > 55 ? Font(fontHeight).getStringWidth(labelText) : fontWidth * (labelText.length() + 1); + return { posx, posy, textWidth, fontHeight + 2 }; } } diff --git a/Source/Objects/ScalarObject.h b/Source/Objects/ScalarObject.h index 2ff46db43..74c98ed39 100644 --- a/Source/Objects/ScalarObject.h +++ b/Source/Objects/ScalarObject.h @@ -443,7 +443,7 @@ class DrawableSymbol final : public DrawableTemplate if (type < 0) buf[0] = 0; else { - strncpy(buf, object->x_label->s_name, DRAWNUMBER_BUFSIZE); + strncpy(buf, object->x_label->s_name, DRAWNUMBER_BUFSIZE-1); buf[DRAWNUMBER_BUFSIZE - 1] = 0; int const nchars = static_cast(strlen(buf)); if (type == DT_TEXT) { diff --git a/Source/Sidebar/CommandInput.h b/Source/Sidebar/CommandInput.h index e7d00ae55..b943e9261 100644 --- a/Source/Sidebar/CommandInput.h +++ b/Source/Sidebar/CommandInput.h @@ -762,7 +762,7 @@ class CommandInput final currentHistoryIndex = -1; } else if (currentHistoryIndex < commandHistory.size()) { auto const command = commandHistory[currentHistoryIndex]; - if (auto const isMultiLine = command.containsChar('\n')) + if (command.containsChar('\n')) setConsoleTargetName("lua"); else updateCommandInputTarget(); diff --git a/Source/TabComponent.cpp b/Source/TabComponent.cpp index 78874fb7a..5fa51dc3c 100644 --- a/Source/TabComponent.cpp +++ b/Source/TabComponent.cpp @@ -1119,7 +1119,7 @@ void TabComponent::showHiddenTabsMenu(int const splitIndex) void paint(Graphics& g) override { - if (auto const isActive = tabbar.getVisibleCanvases().contains(cnv)) { + if (tabbar.getVisibleCanvases().contains(cnv)) { g.setColour(findColour(PlugDataColour::popupMenuActiveBackgroundColourId)); } else if (isItemHighlighted()) { g.setColour(findColour(PlugDataColour::popupMenuActiveBackgroundColourId).interpolatedWith(findColour(PlugDataColour::popupMenuBackgroundColourId), 0.4f)); diff --git a/Source/Utility/CircularBuffer.h b/Source/Utility/CircularBuffer.h index 16694125d..68bd95f70 100644 --- a/Source/Utility/CircularBuffer.h +++ b/Source/Utility/CircularBuffer.h @@ -55,6 +55,6 @@ class CircularBuffer { size_t mask(size_t const val) const { // val = static_cast(val >= 0 ? val : val + static_cast(size)); - return val & size - 1; + return val & (size - 1); } }; diff --git a/Source/Utility/ValueTreeViewer.h b/Source/Utility/ValueTreeViewer.h index 88225913c..fecc52ff0 100644 --- a/Source/Utility/ValueTreeViewer.h +++ b/Source/Utility/ValueTreeViewer.h @@ -245,7 +245,7 @@ class ValueTreeNodeComponent final : public Component { void paint(Graphics& g) override { // Either show single selection or multi-selection - if (auto selected = getOwnerView()->selectedNode ? isSelected() : valueTreeNode.getProperty("Selected") == var(true)) { + if (getOwnerView()->selectedNode ? isSelected() : valueTreeNode.getProperty("Selected") == var(true)) { auto const highlightCol = findColour(PlugDataColour::sidebarActiveBackgroundColourId); g.setColour(isSelected() ? highlightCol.brighter(0.2f) : highlightCol); g.fillRoundedRectangle(getLocalBounds().withHeight(25).reduced(2).toFloat(), Corners::defaultCornerRadius);