diff --git a/examples/Utilities/XMLandJSONDemo.h b/examples/Utilities/XMLandJSONDemo.h index d23efbda1f..3f4d09ee09 100644 --- a/examples/Utilities/XMLandJSONDemo.h +++ b/examples/Utilities/XMLandJSONDemo.h @@ -96,10 +96,8 @@ public: // each sub-element in the XML.. for (auto* child : xml.getChildIterator()) - { - jassert (child != nullptr); - addSubItem (new XmlTreeItem (*child)); - } + if (child != nullptr) + addSubItem (new XmlTreeItem (*child)); } } else diff --git a/extras/Projucer/Source/ComponentEditor/Components/jucer_ComboBoxHandler.h b/extras/Projucer/Source/ComponentEditor/Components/jucer_ComboBoxHandler.h index be39c3f746..2a573c979c 100644 --- a/extras/Projucer/Source/ComponentEditor/Components/jucer_ComboBoxHandler.h +++ b/extras/Projucer/Source/ComponentEditor/Components/jucer_ComboBoxHandler.h @@ -41,18 +41,21 @@ public: XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) override { - ComboBox* const c = dynamic_cast (comp); - jassert (c != nullptr); + if (auto* const c = dynamic_cast (comp)) + { + if (auto* e = ComponentTypeHandler::createXmlFor (comp, layout)) + { + e->setAttribute ("editable", c->isTextEditable()); + e->setAttribute ("layout", c->getJustificationType().getFlags()); + e->setAttribute ("items", c->getProperties() ["items"].toString()); + e->setAttribute ("textWhenNonSelected", c->getTextWhenNothingSelected()); + e->setAttribute ("textWhenNoItems", c->getTextWhenNoChoicesAvailable()); - XmlElement* e = ComponentTypeHandler::createXmlFor (comp, layout); + return e; + } + } - e->setAttribute ("editable", c->isTextEditable()); - e->setAttribute ("layout", c->getJustificationType().getFlags()); - e->setAttribute ("items", c->getProperties() ["items"].toString()); - e->setAttribute ("textWhenNonSelected", c->getTextWhenNothingSelected()); - e->setAttribute ("textWhenNoItems", c->getTextWhenNoChoicesAvailable()); - - return e; + return nullptr; } bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout) override @@ -62,18 +65,20 @@ public: ComboBox defaultBox; - ComboBox* const c = dynamic_cast (comp); - jassert (c != nullptr); + if (ComboBox* const c = dynamic_cast (comp)) + { + c->setEditableText (xml.getBoolAttribute ("editable", defaultBox.isTextEditable())); + c->setJustificationType (Justification (xml.getIntAttribute ("layout", defaultBox.getJustificationType().getFlags()))); + c->getProperties().set ("items", xml.getStringAttribute ("items", String())); + c->setTextWhenNothingSelected (xml.getStringAttribute ("textWhenNonSelected", defaultBox.getTextWhenNothingSelected())); + c->setTextWhenNoChoicesAvailable (xml.getStringAttribute ("textWhenNoItems", defaultBox.getTextWhenNoChoicesAvailable())); - c->setEditableText (xml.getBoolAttribute ("editable", defaultBox.isTextEditable())); - c->setJustificationType (Justification (xml.getIntAttribute ("layout", defaultBox.getJustificationType().getFlags()))); - c->getProperties().set ("items", xml.getStringAttribute ("items", String())); - c->setTextWhenNothingSelected (xml.getStringAttribute ("textWhenNonSelected", defaultBox.getTextWhenNothingSelected())); - c->setTextWhenNoChoicesAvailable (xml.getStringAttribute ("textWhenNoItems", defaultBox.getTextWhenNoChoicesAvailable())); + updateItems (c); - updateItems (c); + return true; + } - return true; + return false; } void getEditableProperties (Component* component, JucerDocument& document, @@ -104,7 +109,12 @@ public: ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName); ComboBox* const c = dynamic_cast (component); - jassert (c != nullptr); + + if (c == nullptr) + { + jassertfalse; + return; + } String s; s << memberVariableName << "->setEditableText (" << CodeHelpers::boolLiteral (c->isTextEditable()) << ");\n" diff --git a/extras/Projucer/Source/ComponentEditor/Components/jucer_ComponentTypeHandler.cpp b/extras/Projucer/Source/ComponentEditor/Components/jucer_ComponentTypeHandler.cpp index 68a368a139..c210099e05 100644 --- a/extras/Projucer/Source/ComponentEditor/Components/jucer_ComponentTypeHandler.cpp +++ b/extras/Projucer/Source/ComponentEditor/Components/jucer_ComponentTypeHandler.cpp @@ -612,7 +612,7 @@ void ComponentTypeHandler::fillInCreationCode (GeneratedCode& code, Component* c s << "addAndMakeVisible (" << memberVariableName << ".get());\n"; - if (SettableTooltipClient* ttc = dynamic_cast (component)) + if (auto* ttc = dynamic_cast (component)) { if (ttc->getTooltip().isNotEmpty()) { @@ -622,7 +622,7 @@ void ComponentTypeHandler::fillInCreationCode (GeneratedCode& code, Component* c } } - if (component->getExplicitFocusOrder() > 0) + if (component != nullptr && component->getExplicitFocusOrder() > 0) s << memberVariableName << "->setExplicitFocusOrder (" << component->getExplicitFocusOrder() << ");\n"; diff --git a/extras/Projucer/Source/ComponentEditor/Components/jucer_SliderHandler.h b/extras/Projucer/Source/ComponentEditor/Components/jucer_SliderHandler.h index abcc52ccb3..dd087facc0 100644 --- a/extras/Projucer/Source/ComponentEditor/Components/jucer_SliderHandler.h +++ b/extras/Projucer/Source/ComponentEditor/Components/jucer_SliderHandler.h @@ -544,15 +544,15 @@ private: String getText() const override { - Slider* s = dynamic_cast (component); - jassert (s != nullptr); - - switch (rangeParam) + if (auto* s = dynamic_cast (component)) { - case 0: return String (s->getMinimum()); - case 1: return String (s->getMaximum()); - case 2: return String (s->getInterval()); - default: jassertfalse; break; + switch (rangeParam) + { + case 0: return String (s->getMinimum()); + case 1: return String (s->getMaximum()); + case 2: return String (s->getInterval()); + default: jassertfalse; break; + } } return {}; @@ -613,10 +613,10 @@ private: String getText() const override { - auto s = dynamic_cast (component); - jassert (s != nullptr); + if (auto* s = dynamic_cast (component)) + return String (s->getSkewFactor()); - return String (s->getSkewFactor()); + return {}; } struct SliderSkewChangeAction : public ComponentUndoableAction diff --git a/extras/Projucer/Source/ComponentEditor/Components/jucer_TextEditorHandler.h b/extras/Projucer/Source/ComponentEditor/Components/jucer_TextEditorHandler.h index 65b44771ff..af96ae6209 100644 --- a/extras/Projucer/Source/ComponentEditor/Components/jucer_TextEditorHandler.h +++ b/extras/Projucer/Source/ComponentEditor/Components/jucer_TextEditorHandler.h @@ -114,20 +114,20 @@ public: { ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName); - auto te = dynamic_cast (component); - jassert (te != nullptr); + if (auto* te = dynamic_cast (component)) + { + String s; + s << memberVariableName << "->setMultiLine (" << CodeHelpers::boolLiteral (te->isMultiLine()) << ");\n" + << memberVariableName << "->setReturnKeyStartsNewLine (" << CodeHelpers::boolLiteral (te->getReturnKeyStartsNewLine()) << ");\n" + << memberVariableName << "->setReadOnly (" << CodeHelpers::boolLiteral (te->isReadOnly()) << ");\n" + << memberVariableName << "->setScrollbarsShown (" << CodeHelpers::boolLiteral (te->areScrollbarsShown()) << ");\n" + << memberVariableName << "->setCaretVisible (" << CodeHelpers::boolLiteral (te->isCaretVisible()) << ");\n" + << memberVariableName << "->setPopupMenuEnabled (" << CodeHelpers::boolLiteral (te->isPopupMenuEnabled()) << ");\n" + << getColourIntialisationCode (component, memberVariableName) + << memberVariableName << "->setText (" << quotedString (te->getProperties() ["initialText"].toString(), code.shouldUseTransMacro()) << ");\n\n"; - String s; - s << memberVariableName << "->setMultiLine (" << CodeHelpers::boolLiteral (te->isMultiLine()) << ");\n" - << memberVariableName << "->setReturnKeyStartsNewLine (" << CodeHelpers::boolLiteral (te->getReturnKeyStartsNewLine()) << ");\n" - << memberVariableName << "->setReadOnly (" << CodeHelpers::boolLiteral (te->isReadOnly()) << ");\n" - << memberVariableName << "->setScrollbarsShown (" << CodeHelpers::boolLiteral (te->areScrollbarsShown()) << ");\n" - << memberVariableName << "->setCaretVisible (" << CodeHelpers::boolLiteral (te->isCaretVisible()) << ");\n" - << memberVariableName << "->setPopupMenuEnabled (" << CodeHelpers::boolLiteral (te->isPopupMenuEnabled()) << ");\n" - << getColourIntialisationCode (component, memberVariableName) - << memberVariableName << "->setText (" << quotedString (te->getProperties() ["initialText"].toString(), code.shouldUseTransMacro()) << ");\n\n"; - - code.constructorCode += s; + code.constructorCode += s; + } } private: diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_ColouredElement.cpp b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_ColouredElement.cpp index 1b2ca406d7..72decd397a 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_ColouredElement.cpp +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_ColouredElement.cpp @@ -273,7 +273,11 @@ public: PathStrokeType::curved, PathStrokeType::beveled }; - jassert (newIndex >= 0 && newIndex < 3); + if (! isPositiveAndBelow (newIndex, numElementsInArray (joints))) + { + jassertfalse; + return; + } listener.owner->setStrokeType (PathStrokeType (listener.owner->getStrokeType().stroke.getStrokeThickness(), joints [newIndex], @@ -318,7 +322,11 @@ public: PathStrokeType::square, PathStrokeType::rounded }; - jassert (newIndex >= 0 && newIndex < 3); + if (! isPositiveAndBelow (newIndex, numElementsInArray (ends))) + { + jassertfalse; + return; + } listener.owner->setStrokeType (PathStrokeType (listener.owner->getStrokeType().stroke.getStrokeThickness(), listener.owner->getStrokeType().stroke.getJointStyle(), diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h index 6eafb5864c..77e60798f2 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_FillType.h @@ -89,6 +89,12 @@ public: //============================================================================== void setFillType (Graphics& g, JucerDocument* const document, const Rectangle& parentArea) { + if (document == nullptr) + { + jassertfalse; + return; + } + if (mode == solidColour) { image = Image(); @@ -96,7 +102,6 @@ public: } else if (mode == imageBrush) { - jassert (document != nullptr); loadImage (document); Rectangle r (imageAnchor.getRectangle (parentArea, document->getComponentLayout())); diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp index d803077869..12d5b1df0b 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElement.cpp @@ -584,7 +584,7 @@ void PaintElement::applyBoundsToComponent (Component&, Rectangle newBounds) { for (auto selectedElement : owner->getSelectedElements()) { - if (selectedElement != this) + if (selectedElement != nullptr && selectedElement != this) { if (auto* pe = dynamic_cast (selectedElement->getParentComponent())) { diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.cpp b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.cpp index 0f74d5c90f..4b47ff28d6 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.cpp +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.cpp @@ -77,20 +77,21 @@ private: { showCorrectTab(); - PaintElementPath* const path = getElement(); - jassert (path != nullptr); + if (auto* const path = getElement()) + { + if (auto* const p = path->getPoint (index)) + { + const auto typeChanged = (p->type != value.type); + *p = value; + p->owner = path; - PathPoint* const p = path->getPoint (index); - jassert (p != nullptr); + if (typeChanged) + path->pointListChanged(); - const bool typeChanged = (p->type != value.type); - *p = value; - p->owner = path; + path->changed(); + } + } - if (typeChanged) - path->pointListChanged(); - - path->changed(); return true; } }; @@ -849,14 +850,15 @@ public: { showCorrectTab(); - PaintElementPath* const path = getElement(); - jassert (path != nullptr); + if (auto* const path = getElement()) + { + if (auto* const p = path->addPoint (pointIndexToAddItAfter, false)) + { + indexAdded = path->indexOfPoint (p); + jassert (indexAdded >= 0); + } + } - PathPoint* const p = path->addPoint (pointIndexToAddItAfter, false); - jassert (p != nullptr); - - indexAdded = path->indexOfPoint (p); - jassert (indexAdded >= 0); return true; } @@ -1012,6 +1014,12 @@ bool PaintElementPath::getPoint (int index, int pointNumber, double& x, double& return false; } + if (pointNumber >= PathPoint::maxRects) + { + jassertfalse; + return false; + } + jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo); jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo); @@ -1117,6 +1125,12 @@ void PaintElementPath::movePoint (int index, int pointNumber, jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo); jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo); + if (pointNumber >= PathPoint::maxRects) + { + jassertfalse; + return; + } + RelativePositionedRectangle& pr = newPoint.pos [pointNumber]; double x, y, w, h; @@ -1137,6 +1151,12 @@ void PaintElementPath::movePoint (int index, int pointNumber, RelativePositionedRectangle PaintElementPath::getPoint (int index, int pointNumber) const { + if (pointNumber >= PathPoint::maxRects) + { + jassertfalse; + return RelativePositionedRectangle(); + } + if (PathPoint* const p = points [index]) { jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo); @@ -1151,6 +1171,12 @@ RelativePositionedRectangle PaintElementPath::getPoint (int index, int pointNumb void PaintElementPath::setPoint (int index, int pointNumber, const RelativePositionedRectangle& newPos, const bool undoable) { + if (pointNumber >= PathPoint::maxRects) + { + jassertfalse; + return; + } + if (PathPoint* const p = points [index]) { PathPoint newPoint (*p); @@ -1222,17 +1248,17 @@ public: int getIndex() const override { - const PathPoint* const p = owner->getPoint (index); - jassert (p != nullptr); - - switch (p->type) + if (const auto* const p = owner->getPoint (index)) { - case Path::Iterator::startNewSubPath: return 0; - case Path::Iterator::lineTo: return 1; - case Path::Iterator::quadraticTo: return 2; - case Path::Iterator::cubicTo: return 3; - case Path::Iterator::closePath: break; - default: jassertfalse; break; + switch (p->type) + { + case Path::Iterator::startNewSubPath: return 0; + case Path::Iterator::lineTo: return 1; + case Path::Iterator::quadraticTo: return 2; + case Path::Iterator::cubicTo: return 3; + case Path::Iterator::closePath: break; + default: jassertfalse; break; + } } return 0; diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.h b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.h index b11a0b11d4..047d4d9613 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.h +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementPath.h @@ -39,9 +39,11 @@ public: PathPoint& operator= (const PathPoint& other); ~PathPoint(); + static constexpr auto maxRects = 3; + PaintElementPath* owner; Path::Iterator::PathElementType type; - RelativePositionedRectangle pos [3]; + RelativePositionedRectangle pos [maxRects]; int getNumPoints() const; diff --git a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementUndoableAction.h b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementUndoableAction.h index 7deb19d60f..8c672b4f0e 100644 --- a/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementUndoableAction.h +++ b/extras/Projucer/Source/ComponentEditor/PaintElements/jucer_PaintElementUndoableAction.h @@ -33,18 +33,22 @@ template class PaintElementUndoableAction : public UndoableAction { public: + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) + PaintElementUndoableAction (ElementType* const element) : routine (*element->getOwner()), elementIndex (element->getOwner()->indexOfElement (element)) { jassert (element != nullptr); - if (elementIndex < 0) + if (element != nullptr && elementIndex < 0) findGroupIndices (element->getOwner(), element); jassert (elementIndex >= 0); } + JUCE_END_IGNORE_WARNINGS_MSVC + ElementType* getElement() const { if (containerGroups.size() > 0) diff --git a/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp b/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp index ad12490a97..b5602297b8 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp @@ -572,9 +572,9 @@ PopupMenu ComponentLayout::getRelativeTargetMenu (Component* comp, int whichDime for (int i = 0; i < components.size(); ++i) { - Component* const c = components.getUnchecked(i); + auto* const c = components.getUnchecked (i); - if (c != comp) + if (c != nullptr && c != comp) m.addItem (menuIdBase + i + 1, "Relative to " + getComponentMemberVariableName (c) + " (class: " + ComponentTypeHandler::getHandlerFor (*c)->getClassName (c) + ")", diff --git a/extras/Projucer/Source/Project/UI/Sidebar/jucer_Sidebar.h b/extras/Projucer/Source/Project/UI/Sidebar/jucer_Sidebar.h index e613f22288..a81eca1f24 100644 --- a/extras/Projucer/Source/Project/UI/Sidebar/jucer_Sidebar.h +++ b/extras/Projucer/Source/Project/UI/Sidebar/jucer_Sidebar.h @@ -534,17 +534,19 @@ private: { for (auto i = concertinaPanel.getNumPanels() - 1; i >= 0; --i) { - auto* p = concertinaPanel.getPanel (i); - - if (! (p->isParentOf (e.eventComponent))) + if (auto* p = concertinaPanel.getPanel (i)) { - auto* base = dynamic_cast (p); + if (! (p->isParentOf (e.eventComponent))) + { + auto* base = dynamic_cast (p); - if (base == nullptr) - base = dynamic_cast (p)->getTree(); + if (base == nullptr) + if (auto* concertina = dynamic_cast (p)) + base = concertina->getTree(); - if (base != nullptr) - base->tree.clearSelectedItems(); + if (base != nullptr) + base->tree.clearSelectedItems(); + } } } } diff --git a/extras/Projucer/Source/Project/UI/jucer_ProjectMessagesComponent.h b/extras/Projucer/Source/Project/UI/jucer_ProjectMessagesComponent.h index 2426951506..860c29fce1 100644 --- a/extras/Projucer/Source/Project/UI/jucer_ProjectMessagesComponent.h +++ b/extras/Projucer/Source/Project/UI/jucer_ProjectMessagesComponent.h @@ -468,9 +468,8 @@ public: if (currentProject != nullptr) { - auto* projectWindow = ProjucerApplication::getApp().mainWindowList.getMainWindowForFile (currentProject->getFile()); - jassert (projectWindow != nullptr); - messagesWindow = std::make_unique (*this, *projectWindow, *currentProject); + if (auto* projectWindow = ProjucerApplication::getApp().mainWindowList.getMainWindowForFile (currentProject->getFile())) + messagesWindow = std::make_unique (*this, *projectWindow, *currentProject); auto projectMessagesTree = currentProject->getProjectMessages(); diff --git a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp index b54c587820..b6e7ee8343 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp +++ b/modules/juce_audio_basics/buffers/juce_AudioDataConverters.cpp @@ -480,6 +480,7 @@ public: test (unitTest, true, r); } + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262) static void test (UnitTest& unitTest, bool inPlace, Random& r) { const int numSamples = 2048; @@ -537,6 +538,7 @@ public: unitTest.expect (biggestDiff <= errorMargin); } } + JUCE_END_IGNORE_WARNINGS_MSVC }; template diff --git a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp index e1a2150457..1732ae91d5 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessage.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessage.cpp @@ -287,11 +287,14 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other) { if (other.isHeapAllocated()) { - if (isHeapAllocated()) - packedData.allocatedData = static_cast (std::realloc (packedData.allocatedData, (size_t) other.size)); - else - packedData.allocatedData = static_cast (std::malloc ((size_t) other.size)); + auto* newStorage = static_cast (isHeapAllocated() + ? std::realloc (packedData.allocatedData, (size_t) other.size) + : std::malloc ((size_t) other.size)); + if (newStorage == nullptr) + throw std::bad_alloc{}; // The midi message has not been adjusted at this point + + packedData.allocatedData = newStorage; memcpy (packedData.allocatedData, other.packedData.allocatedData, (size_t) other.size); } else diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp index 84df6f4693..e7d30be6af 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp @@ -833,6 +833,7 @@ public: testLayout.setUpperZone (6); } + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262) void runTest() override { beginTest ("initial zone layout"); @@ -2145,6 +2146,7 @@ public: } } } + JUCE_END_IGNORE_WARNINGS_MSVC private: //============================================================================== diff --git a/modules/juce_audio_basics/utilities/juce_Reverb.h b/modules/juce_audio_basics/utilities/juce_Reverb.h index cf46dccaf0..a1a78b9001 100644 --- a/modules/juce_audio_basics/utilities/juce_Reverb.h +++ b/modules/juce_audio_basics/utilities/juce_Reverb.h @@ -131,6 +131,7 @@ public: /** Applies the reverb to two stereo channels of audio data. */ void processStereo (float* const left, float* const right, const int numSamples) noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) jassert (left != nullptr && right != nullptr); for (int i = 0; i < numSamples; ++i) @@ -160,11 +161,13 @@ public: left[i] = outL * wet1 + outR * wet2 + left[i] * dry; right[i] = outR * wet1 + outL * wet2 + right[i] * dry; } + JUCE_END_IGNORE_WARNINGS_MSVC } /** Applies the reverb to a single mono channel of audio data. */ void processMono (float* const samples, const int numSamples) noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) jassert (samples != nullptr); for (int i = 0; i < numSamples; ++i) @@ -186,6 +189,7 @@ public: samples[i] = output * wet1 + samples[i] * dry; } + JUCE_END_IGNORE_WARNINGS_MSVC } private: diff --git a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp index 3eb960c4b1..6d81ba1bac 100644 --- a/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp +++ b/modules/juce_audio_devices/audio_io/juce_AudioDeviceManager.cpp @@ -857,8 +857,9 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat auto* src = testSound->getReadPointer (0, testSoundPosition); for (int i = 0; i < numOutputChannels; ++i) - for (int j = 0; j < numSamps; ++j) - outputChannelData [i][j] += src[j]; + if (auto* dst = outputChannelData [i]) + for (int j = 0; j < numSamps; ++j) + dst[j] += src[j]; testSoundPosition += numSamps; diff --git a/modules/juce_audio_devices/midi_io/ump/juce_UMPTests.cpp b/modules/juce_audio_devices/midi_io/ump/juce_UMPTests.cpp index a3640f0643..3ea4423040 100644 --- a/modules/juce_audio_devices/midi_io/ump/juce_UMPTests.cpp +++ b/modules/juce_audio_devices/midi_io/ump/juce_UMPTests.cpp @@ -697,7 +697,7 @@ public: for (const auto typecode : typecodesX1) { Packets p; - p.add (PacketX1 { (uint32_t) (typecode << 0x1c | (random.nextInt64() & 0xffffff)) }); + p.add (PacketX1 { (uint32_t) ((int64_t) typecode << 0x1c | (random.nextInt64() & 0xffffff)) }); checkMidi2ToMidi1Conversion (p, p); } @@ -966,8 +966,10 @@ private: template void forEachNonSysExTestMessage (Random& random, Fn&& fn) { - for (uint8_t firstByte = 0x80; firstByte != 0x00; ++firstByte) + for (uint16_t counter = 0x80; counter != 0x100; ++counter) { + const auto firstByte = (uint8_t) counter; + if (firstByte == 0xf0 || firstByte == 0xf7) continue; // sysEx is tested separately diff --git a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp index 2383ae9161..535c693091 100644 --- a/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp +++ b/modules/juce_audio_devices/native/juce_win32_DirectSound.cpp @@ -211,12 +211,17 @@ namespace { if (dsDirectSoundCreate == nullptr) { - HMODULE h = LoadLibraryA ("dsound.dll"); + if (auto* h = LoadLibraryA ("dsound.dll")) + { + DSOUND_FUNCTION_LOAD (DirectSoundCreate) + DSOUND_FUNCTION_LOAD (DirectSoundCaptureCreate) + DSOUND_FUNCTION_LOAD (DirectSoundEnumerateW) + DSOUND_FUNCTION_LOAD (DirectSoundCaptureEnumerateW) - DSOUND_FUNCTION_LOAD (DirectSoundCreate) - DSOUND_FUNCTION_LOAD (DirectSoundCaptureCreate) - DSOUND_FUNCTION_LOAD (DirectSoundEnumerateW) - DSOUND_FUNCTION_LOAD (DirectSoundCaptureEnumerateW) + return; + } + + jassertfalse; } } diff --git a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp index a06087e815..c9d385fa39 100644 --- a/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp @@ -97,7 +97,7 @@ namespace FlacNamespace #define FLAC__NO_DLL 1 - JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4312 4505 4365 4005 4334 181 111) + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4312 4505 4365 4005 4334 181 111 6340 6308 6297 6001) #if ! JUCE_MSVC #define HAVE_LROUND 1 #endif diff --git a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index f355b644f5..49bf0fe295 100644 --- a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp @@ -2409,6 +2409,7 @@ private: return numBits; } + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6385) int getLayer3ScaleFactors2 (int* scf, Layer3SideInfo::Info& granule, const bool iStereo) noexcept { static const uint8 scaleTable[3][6][4] = @@ -2460,6 +2461,7 @@ private: return numBits; } + JUCE_END_IGNORE_WARNINGS_MSVC bool layer3DequantizeSample (float xr[32][18], int* scf, Layer3SideInfo::Info& granule, int sampleRate, int part2bits) noexcept { @@ -2926,7 +2928,7 @@ private: sum += window[12] * b0[12]; sum += window[14] * b0[14]; *out++ = sum; b0 -= 16; window -= 32; - window += bo1 << 1; + window += (ptrdiff_t) bo1 << 1; } for (int j = 15; j != 0; --j, b0 -= 16, window -= 32) @@ -2976,7 +2978,11 @@ public: bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) override { - jassert (destSamples != nullptr); + if (destSamples == nullptr) + { + jassertfalse; + return false; + } if (currentPosition != startSampleInFile) { diff --git a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp index d2410edfc7..387ace0c04 100644 --- a/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp @@ -35,7 +35,7 @@ namespace juce namespace OggVorbisNamespace { #if JUCE_INCLUDE_OGGVORBIS_CODE || ! defined (JUCE_INCLUDE_OGGVORBIS_CODE) - JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706 4995 4365 4456 4457 4459) + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706 4995 4365 4456 4457 4459 6297 6011 6001 6308 6255 6386 6385 6246 6387 6263 6262 28182) JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wconversion", "-Wshadow", diff --git a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index 2fe0aadba8..a164928d4f 100644 --- a/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -231,6 +231,7 @@ public: for (int i = 0; i < numDestChannels; ++i) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182) jassert (destSamples[i] != nullptr); auto srcChan = jmin (i, (int) numChannels - 1); @@ -242,6 +243,7 @@ public: dst[j] = ((uint32) *src) << 16; src += numChannels; } + JUCE_END_IGNORE_WARNINGS_MSVC } startSampleInFile += numToDo; @@ -260,7 +262,7 @@ private: void checkCoInitialiseCalled() { - CoInitialize (0); + ignoreUnused (CoInitialize (0)); } void scanFileForDetails() diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp index 3b667f0f33..2e4651240f 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.cpp @@ -175,8 +175,12 @@ void AudioFormatReader::read (AudioBuffer* buffer, read (chans, 2, readerStartSample, numSamples, true); // if the target's stereo and the source is mono, dupe the first channel.. - if (numTargetChannels > 1 && (chans[0] == nullptr || chans[1] == nullptr)) + if (numTargetChannels > 1 + && (chans[0] == nullptr || chans[1] == nullptr) + && (dests[0] != nullptr && dests[1] != nullptr)) + { memcpy (dests[1], dests[0], (size_t) numSamples * sizeof (float)); + } if (! usesFloatingPointData) convertFixedToFloat (dests, 2, numSamples); diff --git a/modules/juce_audio_formats/format/juce_AudioFormatReader.h b/modules/juce_audio_formats/format/juce_AudioFormatReader.h index da06645b01..970d1ae10c 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatReader.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatReader.h @@ -306,7 +306,12 @@ protected: int startOffsetInDestBuffer, int64 startSampleInFile, int& numSamples, int64 fileLengthInSamples) { - jassert (destChannels != nullptr); + if (destChannels == nullptr) + { + jassertfalse; + return; + } + const int64 samplesAvailable = fileLengthInSamples - startSampleInFile; if (samplesAvailable < numSamples) diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index afe3ee7c44..d74c7986c2 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -157,16 +157,16 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int if (isFloatingPoint()) return write ((const int**) channels, numSamples); - int* chans[256]; - int scratch[4096]; + std::vector chans (256); + std::vector scratch (4096); - jassert (numSourceChannels < numElementsInArray (chans)); - const int maxSamples = (int) (numElementsInArray (scratch) / numSourceChannels); + jassert (numSourceChannels < (int) chans.size()); + const int maxSamples = (int) scratch.size() / numSourceChannels; for (int i = 0; i < numSourceChannels; ++i) - chans[i] = scratch + (i * maxSamples); + chans[(size_t) i] = scratch.data() + (i * maxSamples); - chans[numSourceChannels] = nullptr; + chans[(size_t) numSourceChannels] = nullptr; int startSample = 0; while (numSamples > 0) @@ -174,9 +174,9 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int auto numToDo = jmin (numSamples, maxSamples); for (int i = 0; i < numSourceChannels; ++i) - convertFloatsToInts (chans[i], channels[i] + startSample, numToDo); + convertFloatsToInts (chans[(size_t) i], channels[(size_t) i] + startSample, numToDo); - if (! write ((const int**) chans, numToDo)) + if (! write ((const int**) chans.data(), numToDo)) return false; startSample += numToDo; diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index d510863984..c718d2b5dd 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -1929,7 +1929,9 @@ private: pointer_sized_int handleKeyboardFocusRequired (VstOpCodeArguments) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6326) return (JucePlugin_EditorRequiresKeyboardFocus != 0) ? 1 : 0; + JUCE_END_IGNORE_WARNINGS_MSVC } pointer_sized_int handleGetVstInterfaceVersion (VstOpCodeArguments) diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index 0ff6c2d110..339cb0090f 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -527,7 +527,11 @@ private: { // we need to remain backward compatible with the old bypass id if (vst3WrapperProvidedBypassParam) + { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6240) vstParamID = static_cast ((isUsingManagedParameters() && ! forceLegacyParamIDs) ? paramBypass : numParameters); + JUCE_END_IGNORE_WARNINGS_MSVC + } bypassParamID = vstParamID; } @@ -3683,18 +3687,15 @@ using namespace juce; //============================================================================== // The VST3 plugin entry point. -JUCE_EXPORTED_FUNCTION IPluginFactory* PLUGIN_API GetPluginFactory() +extern "C" SMTG_EXPORT_SYMBOL IPluginFactory* PLUGIN_API GetPluginFactory() { PluginHostType::jucePlugInClientCurrentWrapperType = AudioProcessor::wrapperType_VST3; - #if JUCE_MSVC || (JUCE_WINDOWS && JUCE_CLANG) + #if (JUCE_MSVC || (JUCE_WINDOWS && JUCE_CLANG)) && JUCE_32BIT // Cunning trick to force this function to be exported. Life's too short to // faff around creating .def files for this kind of thing. - #if JUCE_32BIT - #pragma comment(linker, "/EXPORT:GetPluginFactory=_GetPluginFactory@0") - #else - #pragma comment(linker, "/EXPORT:GetPluginFactory=GetPluginFactory") - #endif + // Unnecessary for 64-bit builds because those don't use decorated function names. + #pragma comment(linker, "/EXPORT:GetPluginFactory=_GetPluginFactory@0") #endif if (globalFactory == nullptr) diff --git a/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp b/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp index c3bf144b13..de2f65a3c8 100644 --- a/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp +++ b/modules/juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp @@ -101,16 +101,18 @@ public: static String getParamID (AudioProcessorParameter* param, bool forceLegacyParamIDs) noexcept { if (auto* legacy = dynamic_cast (param)) - { return forceLegacyParamIDs ? String (legacy->parameterIndex) : legacy->getParamID(); - } - else if (auto* paramWithID = dynamic_cast (param)) + + if (auto* paramWithID = dynamic_cast (param)) { if (! forceLegacyParamIDs) return paramWithID->paramID; } - return String (param->getParameterIndex()); + if (param != nullptr) + return String (param->getParameterIndex()); + + return {}; } }; diff --git a/modules/juce_audio_processors/format_types/juce_VST3Headers.h b/modules/juce_audio_processors/format_types/juce_VST3Headers.h index 9c5dd4f985..44224f0a33 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Headers.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Headers.h @@ -28,7 +28,7 @@ #endif // Wow, those Steinberg guys really don't worry too much about compiler warnings. -JUCE_BEGIN_IGNORE_WARNINGS_LEVEL_MSVC (0, 4505 4702) +JUCE_BEGIN_IGNORE_WARNINGS_LEVEL_MSVC (0, 4505 4702 6011 6031 6221 6386 6387 6330 6001) JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wnon-virtual-dtor", "-Wreorder", diff --git a/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h b/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h index 49f0d3b3bd..7e20828923 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h +++ b/modules/juce_audio_processors/format_types/juce_VSTMidiEventList.h @@ -175,11 +175,16 @@ private: static Vst2::VstEvent* allocateVSTEvent() { - auto e = (Vst2::VstEvent*) std::calloc (1, sizeof (Vst2::VstMidiEvent) > sizeof (Vst2::VstMidiSysexEvent) ? sizeof (Vst2::VstMidiEvent) - : sizeof (Vst2::VstMidiSysexEvent)); - e->type = Vst2::kVstMidiType; - e->byteSize = sizeof (Vst2::VstMidiEvent); - return e; + constexpr auto size = jmax (sizeof (Vst2::VstMidiEvent), sizeof (Vst2::VstMidiSysexEvent)); + + if (auto* e = static_cast (std::calloc (1, size))) + { + e->type = Vst2::kVstMidiType; + e->byteSize = sizeof (Vst2::VstMidiEvent); + return e; + } + + return nullptr; } static void freeVSTEvent (Vst2::VstEvent* e) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp index 3bb2e75896..90599802f0 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorParameterGroup.cpp @@ -131,7 +131,7 @@ Array AudioProcessorParameterGroup::getGrou if (auto* group = getGroupForParameter (parameter)) { - while (group != this) + while (group != nullptr && group != this) { groups.insert (0, group); group = group->getParent(); diff --git a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp index 11498611e0..4d49756040 100644 --- a/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_GenericAudioProcessorEditor.cpp @@ -518,6 +518,7 @@ struct GenericAudioProcessorEditor::Pimpl { Pimpl (GenericAudioProcessorEditor& parent) : owner (parent) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) auto* p = parent.getAudioProcessor(); jassert (p != nullptr); @@ -529,6 +530,7 @@ struct GenericAudioProcessorEditor::Pimpl owner.addAndMakeVisible (view); view.setScrollBarsShown (true, false); + JUCE_END_IGNORE_WARNINGS_MSVC } ~Pimpl() diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp index f27070b963..916eb4424f 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.cpp @@ -194,7 +194,12 @@ bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier, for (auto* desc : found) { - jassert (desc != nullptr); + if (desc == nullptr) + { + jassertfalse; + continue; + } + addType (*desc); typesFound.add (new PluginDescription (*desc)); } diff --git a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp index 2d4bfac237..bf4b550266 100644 --- a/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp +++ b/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.cpp @@ -668,6 +668,7 @@ public: : UnitTest ("Audio Processor Value Tree State", UnitTestCategories::audioProcessorParameters) {} + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262) void runTest() override { ScopedJuceInitialiser_GUI scopedJuceInitialiser_gui; @@ -952,6 +953,7 @@ public: expectEquals (listener.id, String (key)); } } + JUCE_END_IGNORE_WARNINGS_MSVC }; static AudioProcessorValueTreeStateTests audioProcessorValueTreeStateTests; diff --git a/modules/juce_box2d/juce_box2d.cpp b/modules/juce_box2d/juce_box2d.cpp index 334a5e3961..fdb2dd19ae 100644 --- a/modules/juce_box2d/juce_box2d.cpp +++ b/modules/juce_box2d/juce_box2d.cpp @@ -34,6 +34,7 @@ #include "juce_box2d.h" +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wconversion", "-Wsign-conversion", "-Wfloat-conversion", @@ -101,3 +102,4 @@ using uint32 = juce::uint32; #include "utils/juce_Box2DRenderer.cpp" JUCE_END_IGNORE_WARNINGS_GCC_LIKE +JUCE_END_IGNORE_WARNINGS_MSVC diff --git a/modules/juce_core/containers/juce_AbstractFifo.cpp b/modules/juce_core/containers/juce_AbstractFifo.cpp index 320c867cca..c4db8d76ee 100644 --- a/modules/juce_core/containers/juce_AbstractFifo.cpp +++ b/modules/juce_core/containers/juce_AbstractFifo.cpp @@ -215,6 +215,8 @@ public: Random random; }; + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262) + void runTest() override { beginTest ("AbstractFifo"); @@ -258,6 +260,8 @@ public: } } } + + JUCE_END_IGNORE_WARNINGS_MSVC }; static AbstractFifoTests fifoUnitTests; diff --git a/modules/juce_core/containers/juce_LinkedListPointer.h b/modules/juce_core/containers/juce_LinkedListPointer.h index 1c2491aa97..1fc5c791e5 100644 --- a/modules/juce_core/containers/juce_LinkedListPointer.h +++ b/modules/juce_core/containers/juce_LinkedListPointer.h @@ -179,10 +179,12 @@ public: */ void insertNext (ObjectType* const newItem) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) jassert (newItem != nullptr); jassert (newItem->nextListItem == nullptr); newItem->nextListItem = item; item = newItem; + JUCE_END_IGNORE_WARNINGS_MSVC } /** Inserts an item at a numeric index in the list. @@ -208,6 +210,7 @@ public: */ ObjectType* replaceNext (ObjectType* const newItem) noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011 28182) jassert (newItem != nullptr); jassert (newItem->nextListItem == nullptr); @@ -216,6 +219,7 @@ public: item->nextListItem = oldItem->nextListItem.item; oldItem->nextListItem.item = nullptr; return oldItem; + JUCE_END_IGNORE_WARNINGS_MSVC } /** Adds an item to the end of the list. @@ -308,10 +312,13 @@ public: */ void copyToArray (ObjectType** destArray) const noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) jassert (destArray != nullptr); for (auto* i = item; i != nullptr; i = i->nextListItem) *destArray++ = i; + + JUCE_END_IGNORE_WARNINGS_MSVC } /** Swaps this pointer with another one */ diff --git a/modules/juce_core/containers/juce_OwnedArray.cpp b/modules/juce_core/containers/juce_OwnedArray.cpp index eb64a16d2c..0897a14748 100644 --- a/modules/juce_core/containers/juce_OwnedArray.cpp +++ b/modules/juce_core/containers/juce_OwnedArray.cpp @@ -57,7 +57,9 @@ static struct OwnedArrayTest : public UnitTest { parent.expect (o != nullptr); parent.expect (o != this); - parent.expectEquals (o->data, 956); + + if (o != nullptr) + parent.expectEquals (o->data, 956); } } diff --git a/modules/juce_core/containers/juce_ReferenceCountedArray.cpp b/modules/juce_core/containers/juce_ReferenceCountedArray.cpp index 8ef9c28fdb..ee28571102 100644 --- a/modules/juce_core/containers/juce_ReferenceCountedArray.cpp +++ b/modules/juce_core/containers/juce_ReferenceCountedArray.cpp @@ -158,7 +158,9 @@ private: { parent.expect (o != nullptr); parent.expect (o != this); - parent.expectEquals (o->data, 374); + + if (o != nullptr) + parent.expectEquals (o->data, 374); } } diff --git a/modules/juce_core/maths/juce_Expression.cpp b/modules/juce_core/maths/juce_Expression.cpp index 211860d89f..6c3a21caed 100644 --- a/modules/juce_core/maths/juce_Expression.cpp +++ b/modules/juce_core/maths/juce_Expression.cpp @@ -571,7 +571,11 @@ struct Expression::Helpers static Constant* findTermToAdjust (Term* const term, const bool mustBeFlagged) { - jassert (term != nullptr); + if (term == nullptr) + { + jassertfalse; + return nullptr; + } if (term->getType() == constantType) { diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 9547df8c24..a36bf30e0a 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -717,7 +717,7 @@ static String readWindowsLnkFile (File lnkFile, bool wantsAbsolutePath) && SUCCEEDED (persistFile->Load (lnkFile.getFullPathName().toWideCharPointer(), STGM_READ)) && (! wantsAbsolutePath || SUCCEEDED (shellLink->Resolve (nullptr, SLR_ANY_MATCH | SLR_NO_UI)))) { - WIN32_FIND_DATA winFindData; + WIN32_FIND_DATA winFindData = {}; WCHAR resolvedPath[MAX_PATH]; DWORD flags = SLGP_UNCPRIORITY; @@ -861,7 +861,7 @@ bool File::createShortcut (const String& description, const File& linkFileToCrea ComSmartPtr shellLink; ComSmartPtr persistFile; - CoInitialize (nullptr); + ignoreUnused (CoInitialize (nullptr)); return SUCCEEDED (shellLink.CoCreateInstance (CLSID_ShellLink)) && SUCCEEDED (shellLink->SetPath (getFullPathName().toWideCharPointer())) diff --git a/modules/juce_core/native/juce_win32_Network.cpp b/modules/juce_core/native/juce_win32_Network.cpp index 5132648a95..2008b9c403 100644 --- a/modules/juce_core/native/juce_win32_Network.cpp +++ b/modules/juce_core/native/juce_win32_Network.cpp @@ -177,7 +177,14 @@ public: int read (void* buffer, int bytesToRead) { - jassert (buffer != nullptr && bytesToRead >= 0); + jassert (bytesToRead >= 0); + + if (buffer == nullptr) + { + jassertfalse; + return 0; + } + DWORD bytesRead = 0; if (! (finished || isError())) diff --git a/modules/juce_core/native/juce_win32_Threads.cpp b/modules/juce_core/native/juce_win32_Threads.cpp index 4a41481199..f0bff4d039 100644 --- a/modules/juce_core/native/juce_win32_Threads.cpp +++ b/modules/juce_core/native/juce_win32_Threads.cpp @@ -28,8 +28,12 @@ HWND juce_messageWindowHandle = nullptr; // (this is used by other parts of the void* getUser32Function (const char* functionName) { HMODULE module = GetModuleHandleA ("user32.dll"); - jassert (module != nullptr); - return (void*) GetProcAddress (module, functionName); + + if (module != nullptr) + return (void*) GetProcAddress (module, functionName); + + jassertfalse; + return nullptr; } //============================================================================== @@ -85,7 +89,10 @@ void Thread::killThread() #if JUCE_DEBUG OutputDebugStringA ("** Warning - Forced thread termination **\n"); #endif + + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6258) TerminateThread (threadHandle.get(), 0); + JUCE_END_IGNORE_WARNINGS_MSVC } } @@ -109,8 +116,11 @@ void JUCE_CALLTYPE Thread::setCurrentThreadName (const String& name) { RaiseException (0x406d1388 /*MS_VC_EXCEPTION*/, 0, sizeof (info) / sizeof (ULONG_PTR), (ULONG_PTR*) &info); } - __except (EXCEPTION_CONTINUE_EXECUTION) - {} + __except (GetExceptionCode() == EXCEPTION_NONCONTINUABLE_EXCEPTION ? EXCEPTION_EXECUTE_HANDLER + : EXCEPTION_CONTINUE_EXECUTION) + { + OutputDebugStringA ("** Warning - Encountered noncontinuable exception **\n"); + } #else ignoreUnused (name); #endif @@ -404,9 +414,11 @@ public: startupInfo.hStdError = (streamFlags & wantStdErr) != 0 ? writePipe : nullptr; startupInfo.dwFlags = STARTF_USESTDHANDLES; + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6335) ok = CreateProcess (nullptr, const_cast (command.toWideCharPointer()), nullptr, nullptr, TRUE, CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT, nullptr, nullptr, &startupInfo, &processInfo) != FALSE; + JUCE_END_IGNORE_WARNINGS_MSVC } } diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index ef313c2a7b..4a23600cc4 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -58,11 +58,9 @@ namespace SocketHelpers if (! socketsStarted) { - socketsStarted = true; - WSADATA wsaData; const WORD wVersionRequested = MAKEWORD (1, 1); - WSAStartup (wVersionRequested, &wsaData); + socketsStarted = WSAStartup (wVersionRequested, &wsaData) == 0; } #endif } diff --git a/modules/juce_core/text/juce_CharPointer_UTF16.h b/modules/juce_core/text/juce_CharPointer_UTF16.h index 5dcf6b8629..bf58ec0a47 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF16.h +++ b/modules/juce_core/text/juce_CharPointer_UTF16.h @@ -486,11 +486,13 @@ public: */ static bool isByteOrderMarkBigEndian (const void* possibleByteOrder) noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182) jassert (possibleByteOrder != nullptr); auto c = static_cast (possibleByteOrder); return c[0] == (uint8) byteOrderMarkBE1 && c[1] == (uint8) byteOrderMarkBE2; + JUCE_END_IGNORE_WARNINGS_MSVC } /** Returns true if the first pair of bytes in this pointer are the UTF16 byte-order mark (little endian). @@ -498,11 +500,13 @@ public: */ static bool isByteOrderMarkLittleEndian (const void* possibleByteOrder) noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182) jassert (possibleByteOrder != nullptr); auto c = static_cast (possibleByteOrder); return c[0] == (uint8) byteOrderMarkLE1 && c[1] == (uint8) byteOrderMarkLE2; + JUCE_END_IGNORE_WARNINGS_MSVC } private: diff --git a/modules/juce_core/text/juce_CharPointer_UTF8.h b/modules/juce_core/text/juce_CharPointer_UTF8.h index 117d021bda..475d84e4d5 100644 --- a/modules/juce_core/text/juce_CharPointer_UTF8.h +++ b/modules/juce_core/text/juce_CharPointer_UTF8.h @@ -274,8 +274,10 @@ public: */ size_t sizeInBytes() const noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6387) jassert (data != nullptr); return strlen (data) + 1; + JUCE_END_IGNORE_WARNINGS_MSVC } /** Returns the number of bytes that would be needed to represent the given @@ -552,12 +554,14 @@ public: */ static bool isByteOrderMark (const void* possibleByteOrder) noexcept { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182) jassert (possibleByteOrder != nullptr); auto c = static_cast (possibleByteOrder); return c[0] == (uint8) byteOrderMark1 && c[1] == (uint8) byteOrderMark2 && c[2] == (uint8) byteOrderMark3; + JUCE_END_IGNORE_WARNINGS_MSVC } private: diff --git a/modules/juce_core/text/juce_TextDiff.cpp b/modules/juce_core/text/juce_TextDiff.cpp index 8b662351e6..315462adbe 100644 --- a/modules/juce_core/text/juce_TextDiff.cpp +++ b/modules/juce_core/text/juce_TextDiff.cpp @@ -116,7 +116,10 @@ struct TextDiffHelpers if (scratchSpace < 4096) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255) auto* scratch = (int*) alloca (scratchSpace); + JUCE_END_IGNORE_WARNINGS_MSVC + return findLongestCommonSubstring (a, lenA, indexInA, b, lenB, indexInB, scratchSpace, scratch); } diff --git a/modules/juce_core/threads/juce_TimeSliceThread.cpp b/modules/juce_core/threads/juce_TimeSliceThread.cpp index ed1bbfe429..068d7dc7e5 100644 --- a/modules/juce_core/threads/juce_TimeSliceThread.cpp +++ b/modules/juce_core/threads/juce_TimeSliceThread.cpp @@ -108,7 +108,7 @@ TimeSliceClient* TimeSliceThread::getNextClient (int index) const { auto* c = clients.getUnchecked ((i + index) % clients.size()); - if (client == nullptr || c->nextCallTime < soonest) + if (c != nullptr && (client == nullptr || c->nextCallTime < soonest)) { client = c; soonest = c->nextCallTime; diff --git a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp index b3403d169a..f29f3d73c3 100644 --- a/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp @@ -23,7 +23,7 @@ namespace juce { -JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4309 4305 4365) +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4309 4305 4365 6385 6326 6340) namespace zlibNamespace { diff --git a/modules/juce_data_structures/values/juce_ValueTree.cpp b/modules/juce_data_structures/values/juce_ValueTree.cpp index 704ddf8110..0d79f9e8dc 100644 --- a/modules/juce_data_structures/values/juce_ValueTree.cpp +++ b/modules/juce_data_structures/values/juce_ValueTree.cpp @@ -949,19 +949,16 @@ void ValueTree::moveChild (int currentIndex, int newIndex, UndoManager* undoMana //============================================================================== void ValueTree::createListOfChildren (OwnedArray& list) const { - jassert (object != nullptr); - - for (auto* o : object->children) - { - jassert (o != nullptr); - list.add (new ValueTree (*o)); - } + if (object != nullptr) + for (auto* o : object->children) + if (o != nullptr) + list.add (new ValueTree (*o)); } void ValueTree::reorderChildren (const OwnedArray& newOrder, UndoManager* undoManager) { - jassert (object != nullptr); - object->reorderChildren (newOrder, undoManager); + if (object != nullptr) + object->reorderChildren (newOrder, undoManager); } //============================================================================== diff --git a/modules/juce_dsp/frequency/juce_FFT.cpp b/modules/juce_dsp/frequency/juce_FFT.cpp index 7c206340d4..bb46ae8518 100644 --- a/modules/juce_dsp/frequency/juce_FFT.cpp +++ b/modules/juce_dsp/frequency/juce_FFT.cpp @@ -135,7 +135,9 @@ struct FFTFallback : public FFT::Instance if (scratchSize < maxFFTScratchSpaceToAlloca) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255) performRealOnlyForwardTransform (static_cast*> (alloca (scratchSize)), d); + JUCE_END_IGNORE_WARNINGS_MSVC } else { @@ -153,7 +155,9 @@ struct FFTFallback : public FFT::Instance if (scratchSize < maxFFTScratchSpaceToAlloca) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255) performRealOnlyInverseTransform (static_cast*> (alloca (scratchSize)), d); + JUCE_END_IGNORE_WARNINGS_MSVC } else { @@ -315,13 +319,17 @@ struct FFTFallback : public FFT::Instance default: jassertfalse; break; } + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255) auto* scratch = static_cast*> (alloca ((size_t) factor.radix * sizeof (Complex))); + JUCE_END_IGNORE_WARNINGS_MSVC for (int i = 0; i < factor.length; ++i) { for (int k = i, q1 = 0; q1 < factor.radix; ++q1) { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6386) scratch[q1] = data[k]; + JUCE_END_IGNORE_WARNINGS_MSVC k += factor.length; } @@ -337,7 +345,9 @@ struct FFTFallback : public FFT::Instance if (twiddleIndex >= fftSize) twiddleIndex -= fftSize; + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6385) data[k] += scratch[q] * twiddleTable[twiddleIndex]; + JUCE_END_IGNORE_WARNINGS_MSVC } k += factor.length; diff --git a/modules/juce_dsp/frequency/juce_FFT_test.cpp b/modules/juce_dsp/frequency/juce_FFT_test.cpp index 5befd3d2f1..1abf309d06 100644 --- a/modules/juce_dsp/frequency/juce_FFT_test.cpp +++ b/modules/juce_dsp/frequency/juce_FFT_test.cpp @@ -148,7 +148,7 @@ struct FFTUnitTest : public UnitTest HeapBlock> frequency (n); fillRandom (random, inout.getData(), n); - zeromem (reference.getData(), sizeof (float) * (n << 1)); + zeromem (reference.getData(), sizeof (float) * ((size_t) n << 1)); performReferenceFourier (inout.getData(), frequency.getData(), n, false); for (size_t i = 0; i < n; ++i) diff --git a/modules/juce_dsp/widgets/juce_Bias.h b/modules/juce_dsp/widgets/juce_Bias.h index 7df938dac7..3e42b14c23 100644 --- a/modules/juce_dsp/widgets/juce_Bias.h +++ b/modules/juce_dsp/widgets/juce_Bias.h @@ -128,6 +128,7 @@ public: } else { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6386) auto* biases = static_cast (alloca (sizeof (FloatType) * len)); for (size_t i = 0; i < len; ++i) @@ -137,6 +138,7 @@ public: FloatVectorOperations::add (outBlock.getChannelPointer (chan), inBlock.getChannelPointer (chan), biases, static_cast (len)); + JUCE_END_IGNORE_WARNINGS_MSVC } } diff --git a/modules/juce_dsp/widgets/juce_Gain.h b/modules/juce_dsp/widgets/juce_Gain.h index adb03b1477..f8adfaab8e 100644 --- a/modules/juce_dsp/widgets/juce_Gain.h +++ b/modules/juce_dsp/widgets/juce_Gain.h @@ -124,10 +124,12 @@ public: } else { + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6386) auto* gains = static_cast (alloca (sizeof (FloatType) * len)); for (size_t i = 0; i < len; ++i) gains[i] = gain.getNextValue(); + JUCE_END_IGNORE_WARNINGS_MSVC for (size_t chan = 0; chan < numChannels; ++chan) FloatVectorOperations::multiply (outBlock.getChannelPointer (chan), diff --git a/modules/juce_events/messages/juce_Initialisation.h b/modules/juce_events/messages/juce_Initialisation.h index 2fc9b96c93..4977b443d0 100644 --- a/modules/juce_events/messages/juce_Initialisation.h +++ b/modules/juce_events/messages/juce_Initialisation.h @@ -88,7 +88,10 @@ public: #define START_JUCE_APPLICATION(AppClass) #else #if JUCE_WINDOWS && ! defined (_CONSOLE) - #define JUCE_MAIN_FUNCTION int __stdcall WinMain (struct HINSTANCE__*, struct HINSTANCE__*, char*, int) + #define JUCE_MAIN_FUNCTION \ + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28251) \ + int __stdcall WinMain (struct HINSTANCE__*, struct HINSTANCE__*, char*, int) \ + JUCE_END_IGNORE_WARNINGS_MSVC #define JUCE_MAIN_FUNCTION_ARGS #else #define JUCE_MAIN_FUNCTION int main (int argc, char* argv[]) diff --git a/modules/juce_events/native/juce_win32_Messaging.cpp b/modules/juce_events/native/juce_win32_Messaging.cpp index fa9fe068b3..089df16b93 100644 --- a/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/modules/juce_events/native/juce_win32_Messaging.cpp @@ -288,7 +288,7 @@ void MessageManager::broadcastMessage (const String& value) //============================================================================== void MessageManager::doPlatformSpecificInitialisation() { - OleInitialize (nullptr); + ignoreUnused (OleInitialize (nullptr)); InternalMessageQueue::getInstance(); } diff --git a/modules/juce_graphics/geometry/juce_EdgeTable.cpp b/modules/juce_graphics/geometry/juce_EdgeTable.cpp index 123bfefc43..268fd88fc2 100644 --- a/modules/juce_graphics/geometry/juce_EdgeTable.cpp +++ b/modules/juce_graphics/geometry/juce_EdgeTable.cpp @@ -26,6 +26,8 @@ namespace juce { +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6263 6386) + const int juce_edgeTableDefaultEdgesPerLine = 32; //============================================================================== @@ -838,4 +840,6 @@ bool EdgeTable::isEmpty() noexcept return bounds.getHeight() == 0; } +JUCE_END_IGNORE_WARNINGS_MSVC + } // namespace juce diff --git a/modules/juce_graphics/image_formats/juce_GIFLoader.cpp b/modules/juce_graphics/image_formats/juce_GIFLoader.cpp index 5875e4915a..19887688dd 100644 --- a/modules/juce_graphics/image_formats/juce_GIFLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_GIFLoader.cpp @@ -30,6 +30,8 @@ namespace juce Image juce_loadWithCoreImage (InputStream& input); #else +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6385) + //============================================================================== class GIFLoader { @@ -113,7 +115,8 @@ private: bool getSizeFromHeader (int& w, int& h) { - char b[6]; + // Add an extra byte for the zero terminator + char b[7]{}; if (input.read (b, 6) == 6 && (strncmp ("GIF87a", b, 6) == 0 @@ -412,6 +415,8 @@ private: JUCE_DECLARE_NON_COPYABLE (GIFLoader) }; +JUCE_END_IGNORE_WARNINGS_MSVC + #endif //============================================================================== diff --git a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp index f66defbf75..9386c3e1e4 100644 --- a/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_JPEGLoader.cpp @@ -26,7 +26,7 @@ namespace juce { -JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4365) +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4365 6240 6326 6386 6385 28182 28183 6387 6011 6001) namespace jpeglibNamespace { diff --git a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp index a6c3e38332..cec62e0c4a 100644 --- a/modules/juce_graphics/image_formats/juce_PNGLoader.cpp +++ b/modules/juce_graphics/image_formats/juce_PNGLoader.cpp @@ -26,7 +26,7 @@ namespace juce { -JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4390 4611 4365 4267 4616 2544 2545) +JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4390 4611 4365 4267 4616 2544 2545 6297) namespace zlibNamespace { diff --git a/modules/juce_graphics/native/juce_RenderingHelpers.h b/modules/juce_graphics/native/juce_RenderingHelpers.h index f2b5502261..a44c3d18db 100644 --- a/modules/juce_graphics/native/juce_RenderingHelpers.h +++ b/modules/juce_graphics/native/juce_RenderingHelpers.h @@ -430,19 +430,19 @@ namespace GradientPixelIterators if (vertical) { - scale = roundToInt ((numEntries << (int) numScaleBits) / (double) (p2.y - p1.y)); + scale = roundToInt ((double) ((int64_t) numEntries << (int) numScaleBits) / (double) (p2.y - p1.y)); start = roundToInt (p1.y * (float) scale); } else if (horizontal) { - scale = roundToInt ((numEntries << (int) numScaleBits) / (double) (p2.x - p1.x)); + scale = roundToInt ((double) ((int64_t) numEntries << (int) numScaleBits) / (double) (p2.x - p1.x)); start = roundToInt (p1.x * (float) scale); } else { grad = (p2.getY() - p1.y) / (double) (p1.x - p2.x); yTerm = p1.getY() - p1.x / grad; - scale = roundToInt ((numEntries << (int) numScaleBits) / (yTerm * grad - (p2.y * grad - p2.x))); + scale = roundToInt ((double) ((int64_t) numEntries << (int) numScaleBits) / (yTerm * grad - (p2.y * grad - p2.x))); grad *= scale; } } diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 250df2064b..3bd78925da 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -382,7 +382,9 @@ struct Component::ComponentHelpers if (directParent == parent) return convertFromParentSpace (target, coordInParent); + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); + JUCE_END_IGNORE_WARNINGS_MSVC } template @@ -393,9 +395,13 @@ struct Component::ComponentHelpers if (source == target) return p; + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011) + if (source->isParentOf (target)) return convertFromDistantParentSpace (source, *target, p); + JUCE_END_IGNORE_WARNINGS_MSVC + p = convertToParentSpace (*source, p); source = source->getParentComponent(); } @@ -3014,7 +3020,7 @@ bool Component::isMouseOver (bool includeChildren) const { auto* c = ms.getComponentUnderMouse(); - if (c == this || (includeChildren && isParentOf (c))) + if (c != nullptr && (c == this || (includeChildren && isParentOf (c)))) if (ms.isDragging() || ! (ms.isTouch() || ms.isPen())) if (c->reallyContains (c->getLocalPoint (nullptr, ms.getScreenPosition()).roundToInt(), false)) return true; diff --git a/modules/juce_gui_basics/desktop/juce_Displays.cpp b/modules/juce_gui_basics/desktop/juce_Displays.cpp index 995f161bb4..fe6e6cecd0 100644 --- a/modules/juce_gui_basics/desktop/juce_Displays.cpp +++ b/modules/juce_gui_basics/desktop/juce_Displays.cpp @@ -348,7 +348,9 @@ void Displays::updateToLogical() } } - retVal->isRoot = true; + if (retVal != nullptr) + retVal->isRoot = true; + return retVal; }(); diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index 003ba94d9b..b29e50d76e 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -84,10 +84,8 @@ public: if (isDirectory) { - if (subContentsList == nullptr) + if (subContentsList == nullptr && parentContentsList != nullptr) { - jassert (parentContentsList != nullptr); - auto l = new DirectoryContentsList (parentContentsList->getFilter(), thread); l->setDirectory (file, diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index 218b6b6fd4..ea5fb3a29e 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -220,6 +220,13 @@ bool MultiDocumentPanel::addDocument (Component* const component, bool MultiDocumentPanel::closeDocument (Component* component, const bool checkItsOkToCloseFirst) { + // Intellisense warns about component being uninitialised. + // I'm not sure how a function argument could be uninitialised. + JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6001) + + if (component == nullptr) + return true; + if (components.contains (component)) { if (checkItsOkToCloseFirst && ! tryToCloseDocument (component)) @@ -304,6 +311,8 @@ bool MultiDocumentPanel::closeDocument (Component* component, } return true; + + JUCE_END_IGNORE_WARNINGS_MSVC } int MultiDocumentPanel::getNumDocuments() const noexcept diff --git a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp index 7e888ea9d2..27094fb3fc 100644 --- a/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp +++ b/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp @@ -1747,6 +1747,9 @@ Button* LookAndFeel_V2::createFilenameComponentBrowseButton (const String& text) void LookAndFeel_V2::layoutFilenameComponent (FilenameComponent& filenameComp, ComboBox* filenameBox, Button* browseButton) { + if (browseButton == nullptr || filenameBox == nullptr) + return; + browseButton->setSize (80, filenameComp.getHeight()); if (auto* tb = dynamic_cast (browseButton)) diff --git a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp index 10f1b644e3..91a2314a81 100644 --- a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp +++ b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp @@ -113,7 +113,9 @@ namespace DragAndDropHelpers if (source.ptd != nullptr) { dest.ptd = (DVTARGETDEVICE*) CoTaskMemAlloc (sizeof (DVTARGETDEVICE)); - *(dest.ptd) = *(source.ptd); + + if (dest.ptd != nullptr) + *(dest.ptd) = *(source.ptd); } } @@ -149,7 +151,8 @@ namespace DragAndDropHelpers void* const src = GlobalLock (medium->hGlobal); void* const dst = GlobalAlloc (GMEM_FIXED, len); - memcpy (dst, src, len); + if (src != nullptr && dst != nullptr) + memcpy (dst, src, len); GlobalUnlock (medium->hGlobal); @@ -215,11 +218,20 @@ namespace DragAndDropHelpers for (int i = fileNames.size(); --i >= 0;) totalBytes += CharPointer_UTF16::getBytesRequiredFor (fileNames[i].getCharPointer()) + sizeof (WCHAR); - HDROP hDrop = (HDROP) GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (DROPFILES) + totalBytes + 4); + struct Deleter + { + void operator() (void* ptr) const noexcept { GlobalFree (ptr); } + }; + + auto hDrop = std::unique_ptr ((HDROP) GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (DROPFILES) + totalBytes + 4)); if (hDrop != nullptr) { - auto pDropFiles = (LPDROPFILES) GlobalLock (hDrop); + auto pDropFiles = (LPDROPFILES) GlobalLock (hDrop.get()); + + if (pDropFiles == nullptr) + return nullptr; + pDropFiles->pFiles = sizeof (DROPFILES); pDropFiles->fWide = true; @@ -233,10 +245,10 @@ namespace DragAndDropHelpers *fname = 0; - GlobalUnlock (hDrop); + GlobalUnlock (hDrop.get()); } - return hDrop; + return static_cast (hDrop.release()); } struct DragAndDropJob : public ThreadPoolJob @@ -250,10 +262,10 @@ namespace DragAndDropHelpers JobStatus runJob() override { - OleInitialize (nullptr); + ignoreUnused (OleInitialize (nullptr)); - auto source = new JuceDropSource(); - auto data = new JuceDataObject (&format, &medium); + auto* source = new JuceDropSource(); + auto* data = new JuceDataObject (&format, &medium); DWORD effect; DoDragDrop (data, source, whatToDo, &effect); @@ -332,6 +344,10 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co auto numBytes = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer()); medium.hGlobal = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, numBytes + 2); + + if (medium.hGlobal == nullptr) + return false; + auto* data = static_cast (GlobalLock (medium.hGlobal)); text.copyToUTF16 (data, numBytes + 2); diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index 0b337ec761..8409a23dae 100644 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -507,7 +507,7 @@ private: struct ScopedCoInitialize { // IUnknown_GetWindow will only succeed when instantiated in a single-thread apartment - ScopedCoInitialize() { CoInitializeEx (nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); } + ScopedCoInitialize() { ignoreUnused (CoInitializeEx (nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)); } ~ScopedCoInitialize() { CoUninitialize(); } }; diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index bcb425d28f..23084e64dc 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -353,7 +353,7 @@ static void checkForPointerAPI() //============================================================================== using SetProcessDPIAwareFunc = BOOL (WINAPI*) (); using SetProcessDPIAwarenessContextFunc = BOOL (WINAPI*) (DPI_AWARENESS_CONTEXT); -using SetProcessDPIAwarenessFunc = BOOL (WINAPI*) (DPI_Awareness); +using SetProcessDPIAwarenessFunc = HRESULT (WINAPI*) (DPI_Awareness); using SetThreadDPIAwarenessContextFunc = DPI_AWARENESS_CONTEXT (WINAPI*) (DPI_AWARENESS_CONTEXT); using GetDPIForWindowFunc = UINT (WINAPI*) (HWND); using GetDPIForMonitorFunc = HRESULT (WINAPI*) (HMONITOR, Monitor_DPI_Type, UINT*, UINT*); @@ -406,7 +406,7 @@ static void setDPIAwareness() setProcessDPIAwarenessContext = (SetProcessDPIAwarenessContextFunc) getUser32Function ("SetProcessDpiAwarenessContext"); if (setProcessDPIAwarenessContext != nullptr - && SUCCEEDED (setProcessDPIAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2))) + && setProcessDPIAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)) return; enableNonClientDPIScaling = (EnableNonClientDPIScalingFunc) getUser32Function ("EnableNonClientDpiScaling"); @@ -874,7 +874,8 @@ public: hBitmap = CreateDIBSection (hdc, (BITMAPINFO*) &(bitmapInfo), DIB_RGB_COLORS, (void**) &bitmapData, nullptr, 0); - previousBitmap = SelectObject (hdc, hBitmap); + if (hBitmap != nullptr) + previousBitmap = SelectObject (hdc, hBitmap); if (format == Image::ARGB && clearImage) zeromem (bitmapData, (size_t) std::abs (h * lineStride)); @@ -1030,7 +1031,7 @@ namespace IconConverters ScopedICONINFO info; - if (! SUCCEEDED (::GetIconInfo (icon, &info))) + if (! ::GetIconInfo (icon, &info)) return {}; BITMAP bm; @@ -1878,7 +1879,7 @@ public: { FORMATETC format = { type, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - if (SUCCEEDED (error = dataObject->GetData (&format, &medium))) + if (SUCCEEDED (error = dataObject->GetData (&format, &medium)) && medium.hGlobal != nullptr) { dataSize = GlobalSize (medium.hGlobal); data = GlobalLock (medium.hGlobal); @@ -1887,7 +1888,7 @@ public: ~DroppedData() { - if (data != nullptr) + if (data != nullptr && medium.hGlobal != nullptr) GlobalUnlock (medium.hGlobal); } @@ -3153,7 +3154,7 @@ private: const UINT keyChar = MapVirtualKey ((UINT) key, 2); const UINT scanCode = MapVirtualKey ((UINT) key, 0); BYTE keyState[256]; - GetKeyboardState (keyState); + ignoreUnused (GetKeyboardState (keyState)); WCHAR text[16] = { 0 }; if (ToUnicode ((UINT) key, scanCode, keyState, text, 8, 0) != 1) @@ -4351,7 +4352,7 @@ static BOOL CALLBACK enumAlwaysOnTopWindows (HWND hwnd, LPARAM lParam) if (processID == GetCurrentProcessId()) { - WINDOWINFO info; + WINDOWINFO info{}; if (GetWindowInfo (hwnd, &info) && (info.dwExStyle & WS_EX_TOPMOST) != 0) @@ -4642,7 +4643,7 @@ void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable, if (auto* tlw = dynamic_cast (kioskModeComp)) tlw->setUsingNativeTitleBar (! enableOrDisable); - if (enableOrDisable) + if (kioskModeComp != nullptr && enableOrDisable) kioskModeComp->setBounds (getDisplays().getDisplayForRect (kioskModeComp->getScreenBounds())->totalArea); } diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 6d18923a2d..1ade565757 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -150,7 +150,7 @@ void Label::attachToComponent (Component* owner, bool onLeft) if (ownerComponent != nullptr) { - setVisible (owner->isVisible()); + setVisible (ownerComponent->isVisible()); ownerComponent->addComponentListener (this); componentParentHierarchyChanged (*ownerComponent); componentMovedOrResized (*ownerComponent, true, true); diff --git a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp index 1b9cb89711..97cf5034d7 100644 --- a/modules/juce_gui_basics/widgets/juce_Toolbar.cpp +++ b/modules/juce_gui_basics/widgets/juce_Toolbar.cpp @@ -163,7 +163,7 @@ public: { auto* tc = bar.items.getUnchecked(i); - if (dynamic_cast (tc) == nullptr && ! tc->isVisible()) + if (tc != nullptr && dynamic_cast (tc) == nullptr && ! tc->isVisible()) { oldIndexes.insert (0, i); addAndMakeVisible (tc, 0); diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.cpp b/modules/juce_gui_basics/widgets/juce_TreeView.cpp index 2d33493d84..998fb03bfb 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.cpp +++ b/modules/juce_gui_basics/widgets/juce_TreeView.cpp @@ -506,7 +506,12 @@ private: if (modifiers.isShiftDown() && ((firstSelected = owner.getSelectedItem (0)) != nullptr)) { auto* lastSelected = owner.getSelectedItem (owner.getNumSelectedItems() - 1); - jassert (lastSelected != nullptr); + + if (lastSelected == nullptr) + { + jassertfalse; + return; + } auto rowStart = firstSelected->getRowNumberInTree(); auto rowEnd = lastSelected->getRowNumberInTree(); diff --git a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp index be9b821356..aa8b12f85e 100644 --- a/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_TooltipWindow.cpp @@ -108,7 +108,7 @@ void TooltipWindow::displayTip (Point screenPos, const String& tip) for (auto* w : activeTooltipWindows) { - if (w != this && w->tipShowing == tipShowing && w->getParentComponent() == parent) + if (w != nullptr && w != this && w->tipShowing == tipShowing && w->getParentComponent() == parent) { // Looks like you have more than one TooltipWindow showing the same tip.. // Be careful not to create more than one instance of this class with the diff --git a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp index 5f799e571c..34a6817211 100644 --- a/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_WebBrowserComponent.cpp @@ -96,12 +96,12 @@ public: if (connectionPoint != nullptr) { - auto* owner = dynamic_cast (Component::getParentComponent()); - jassert (owner != nullptr); - - auto handler = new EventHandler (*owner); - connectionPoint->Advise (handler, &adviseCookie); - handler->Release(); + if (auto* owner = dynamic_cast (Component::getParentComponent())) + { + auto handler = new EventHandler (*owner); + connectionPoint->Advise (handler, &adviseCookie); + handler->Release(); + } } } } diff --git a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp index 75e3f6e0eb..151f86e612 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp @@ -286,7 +286,7 @@ GLuint OpenGLFrameBuffer::getFrameBufferID() const noexcept GLuint OpenGLFrameBuffer::getCurrentFrameBufferTarget() noexcept { - GLint fb; + GLint fb = {}; glGetIntegerv (GL_FRAMEBUFFER_BINDING, &fb); return (GLuint) fb; } diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 0657ad8b93..0c6fd32376 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -108,9 +108,12 @@ struct CachedImageList : public ReferenceCountedObject, TextureInfo getTextureInfo() { + if (pixelData == nullptr) + return {}; + TextureInfo t; - if (textureNeedsReloading && pixelData != nullptr) + if (textureNeedsReloading) { textureNeedsReloading = false; texture.loadImage (Image (*pixelData)); @@ -1049,7 +1052,11 @@ struct StateHelpers void bindTexture (GLuint textureID) noexcept { - jassert (currentActiveTexture >= 0); + if (currentActiveTexture < 0 || numTextures <= currentActiveTexture) + { + jassertfalse; + return; + } if (currentTextureID[currentActiveTexture] != textureID) { @@ -1068,7 +1075,8 @@ struct StateHelpers } private: - GLuint currentTextureID[3]; + static constexpr auto numTextures = 3; + GLuint currentTextureID[numTextures]; int texturesEnabled = 0, currentActiveTexture = -1; const OpenGLContext& context; diff --git a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp index 4f9c469ce9..2e33d034f5 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp @@ -77,10 +77,10 @@ bool OpenGLShaderProgram::addShader (const String& code, GLenum type) if (status == (GLint) GL_FALSE) { - GLchar infoLog [16384]; + std::vector infoLog (16384); GLsizei infoLogLength = 0; - context.extensions.glGetShaderInfoLog (shaderID, sizeof (infoLog), &infoLogLength, infoLog); - errorLog = String (infoLog, (size_t) infoLogLength); + context.extensions.glGetShaderInfoLog (shaderID, (GLsizei) infoLog.size(), &infoLogLength, infoLog.data()); + errorLog = String (infoLog.data(), (size_t) infoLogLength); #if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR // Your GLSL code contained compile errors! @@ -115,10 +115,10 @@ bool OpenGLShaderProgram::link() noexcept if (status == (GLint) GL_FALSE) { - GLchar infoLog [16384]; + std::vector infoLog (16384); GLsizei infoLogLength = 0; - context.extensions.glGetProgramInfoLog (progID, sizeof (infoLog), &infoLogLength, infoLog); - errorLog = String (infoLog, (size_t) infoLogLength); + context.extensions.glGetProgramInfoLog (progID, (GLsizei) infoLog.size(), &infoLogLength, infoLog.data()); + errorLog = String (infoLog.data(), (size_t) infoLogLength); #if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR // Your GLSL code contained link errors! diff --git a/modules/juce_osc/osc/juce_OSCSender.cpp b/modules/juce_osc/osc/juce_OSCSender.cpp index 527a3290e7..00888a9eae 100644 --- a/modules/juce_osc/osc/juce_OSCSender.cpp +++ b/modules/juce_osc/osc/juce_OSCSender.cpp @@ -461,7 +461,7 @@ public: { // string: expect (testString.length() % 4 != 0); // check whether we actually cover padding - expect (sizeof (testStringRepresentation) % 4 == 0); + static_assert (sizeof (testStringRepresentation) % 4 == 0, "Size must be a multiple of 4"); OSCArgument arg (testString); OSCOutputStream outStream; @@ -474,7 +474,7 @@ public: { // blob: expect (testBlob.getSize() % 4 != 0); // check whether we actually cover padding - expect (sizeof (testBlobRepresentation) % 4 == 0); + static_assert (sizeof (testBlobRepresentation) % 4 == 0, "Size must be a multiple of 4"); OSCArgument arg (testBlob); OSCOutputStream outStream; diff --git a/modules/juce_video/native/juce_win32_CameraDevice.h b/modules/juce_video/native/juce_win32_CameraDevice.h index fcc44b9bfa..fe7e1463a1 100644 --- a/modules/juce_video/native/juce_win32_CameraDevice.h +++ b/modules/juce_video/native/juce_win32_CameraDevice.h @@ -139,9 +139,12 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster AM_MEDIA_TYPE mt = {}; hr = sampleGrabber->GetConnectedMediaType (&mt); - VIDEOINFOHEADER* pVih = (VIDEOINFOHEADER*) (mt.pbFormat); - width = pVih->bmiHeader.biWidth; - height = pVih->bmiHeader.biHeight; + + if (auto* pVih = (VIDEOINFOHEADER*) (mt.pbFormat)) + { + width = pVih->bmiHeader.biWidth; + height = pVih->bmiHeader.biHeight; + } ComSmartPtr nullFilter; hr = nullFilter.CoCreateInstance (CLSID_NullRenderer); @@ -465,6 +468,13 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster int index = 0; ComSmartPtr pDevEnum; + struct Deleter + { + void operator() (IUnknown* ptr) const noexcept { ptr->Release(); } + }; + + using ContextPtr = std::unique_ptr; + if (SUCCEEDED (pDevEnum.CoCreateInstance (CLSID_SystemDeviceEnum))) { ComSmartPtr enumerator; @@ -477,13 +487,20 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster while (enumerator->Next (1, moniker.resetAndGetPointerAddress(), &fetched) == S_OK) { + auto context = [] + { + IBindCtx* ptr = nullptr; + ignoreUnused (CreateBindCtx (0, &ptr)); + return ContextPtr (ptr); + }(); + ComSmartPtr captureFilter; - hr = moniker->BindToObject (0, 0, IID_IBaseFilter, (void**) captureFilter.resetAndGetPointerAddress()); + hr = moniker->BindToObject (context.get(), 0, IID_IBaseFilter, (void**) captureFilter.resetAndGetPointerAddress()); if (SUCCEEDED (hr)) { ComSmartPtr propertyBag; - hr = moniker->BindToStorage (0, 0, IID_IPropertyBag, (void**) propertyBag.resetAndGetPointerAddress()); + hr = moniker->BindToStorage (context.get(), 0, IID_IPropertyBag, (void**) propertyBag.resetAndGetPointerAddress()); if (SUCCEEDED (hr)) { @@ -719,7 +736,7 @@ private: return false; ComSmartPtr moniker; - WCHAR buffer[128]; + WCHAR buffer[128]{}; HRESULT hr = CreateItemMoniker (_T("!"), buffer, moniker.resetAndGetPointerAddress()); if (FAILED (hr)) return false; diff --git a/modules/juce_video/native/juce_win32_Video.h b/modules/juce_video/native/juce_win32_Video.h index fab72585f4..88ad28107e 100644 --- a/modules/juce_video/native/juce_win32_Video.h +++ b/modules/juce_video/native/juce_win32_Video.h @@ -394,7 +394,7 @@ private: { DirectShowContext (Pimpl& c) : component (c) { - CoInitialize (0); + ignoreUnused (CoInitialize (0)); } ~DirectShowContext()