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

Windows: Fix and suppress some analysis warnings

This fixes warnings that are emitted when building with the `-analyze`
flag enabled.
This commit is contained in:
reuk 2021-04-13 22:22:26 +01:00
parent 54423f6583
commit 31a7c62baf
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11
83 changed files with 476 additions and 230 deletions

View file

@ -96,10 +96,8 @@ public:
// each sub-element in the XML.. // each sub-element in the XML..
for (auto* child : xml.getChildIterator()) for (auto* child : xml.getChildIterator())
{ if (child != nullptr)
jassert (child != nullptr); addSubItem (new XmlTreeItem (*child));
addSubItem (new XmlTreeItem (*child));
}
} }
} }
else else

View file

@ -41,18 +41,21 @@ public:
XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) override XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) override
{ {
ComboBox* const c = dynamic_cast<ComboBox*> (comp); if (auto* const c = dynamic_cast<ComboBox*> (comp))
jassert (c != nullptr); {
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()); return nullptr;
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;
} }
bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout) override bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout) override
@ -62,18 +65,20 @@ public:
ComboBox defaultBox; ComboBox defaultBox;
ComboBox* const c = dynamic_cast<ComboBox*> (comp); if (ComboBox* const c = dynamic_cast<ComboBox*> (comp))
jassert (c != nullptr); {
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())); updateItems (c);
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); return true;
}
return true; return false;
} }
void getEditableProperties (Component* component, JucerDocument& document, void getEditableProperties (Component* component, JucerDocument& document,
@ -104,7 +109,12 @@ public:
ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName); ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName);
ComboBox* const c = dynamic_cast<ComboBox*> (component); ComboBox* const c = dynamic_cast<ComboBox*> (component);
jassert (c != nullptr);
if (c == nullptr)
{
jassertfalse;
return;
}
String s; String s;
s << memberVariableName << "->setEditableText (" << CodeHelpers::boolLiteral (c->isTextEditable()) << ");\n" s << memberVariableName << "->setEditableText (" << CodeHelpers::boolLiteral (c->isTextEditable()) << ");\n"

View file

@ -612,7 +612,7 @@ void ComponentTypeHandler::fillInCreationCode (GeneratedCode& code, Component* c
s << "addAndMakeVisible (" << memberVariableName << ".get());\n"; s << "addAndMakeVisible (" << memberVariableName << ".get());\n";
if (SettableTooltipClient* ttc = dynamic_cast<SettableTooltipClient*> (component)) if (auto* ttc = dynamic_cast<SettableTooltipClient*> (component))
{ {
if (ttc->getTooltip().isNotEmpty()) 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 (" s << memberVariableName << "->setExplicitFocusOrder ("
<< component->getExplicitFocusOrder() << component->getExplicitFocusOrder()
<< ");\n"; << ");\n";

View file

@ -544,15 +544,15 @@ private:
String getText() const override String getText() const override
{ {
Slider* s = dynamic_cast<Slider*> (component); if (auto* s = dynamic_cast<Slider*> (component))
jassert (s != nullptr);
switch (rangeParam)
{ {
case 0: return String (s->getMinimum()); switch (rangeParam)
case 1: return String (s->getMaximum()); {
case 2: return String (s->getInterval()); case 0: return String (s->getMinimum());
default: jassertfalse; break; case 1: return String (s->getMaximum());
case 2: return String (s->getInterval());
default: jassertfalse; break;
}
} }
return {}; return {};
@ -613,10 +613,10 @@ private:
String getText() const override String getText() const override
{ {
auto s = dynamic_cast<Slider*> (component); if (auto* s = dynamic_cast<Slider*> (component))
jassert (s != nullptr); return String (s->getSkewFactor());
return String (s->getSkewFactor()); return {};
} }
struct SliderSkewChangeAction : public ComponentUndoableAction<Slider> struct SliderSkewChangeAction : public ComponentUndoableAction<Slider>

View file

@ -114,20 +114,20 @@ public:
{ {
ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName); ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName);
auto te = dynamic_cast<TextEditor*> (component); if (auto* te = dynamic_cast<TextEditor*> (component))
jassert (te != nullptr); {
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; code.constructorCode += 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;
} }
private: private:

View file

@ -273,7 +273,11 @@ public:
PathStrokeType::curved, PathStrokeType::curved,
PathStrokeType::beveled }; PathStrokeType::beveled };
jassert (newIndex >= 0 && newIndex < 3); if (! isPositiveAndBelow (newIndex, numElementsInArray (joints)))
{
jassertfalse;
return;
}
listener.owner->setStrokeType (PathStrokeType (listener.owner->getStrokeType().stroke.getStrokeThickness(), listener.owner->setStrokeType (PathStrokeType (listener.owner->getStrokeType().stroke.getStrokeThickness(),
joints [newIndex], joints [newIndex],
@ -318,7 +322,11 @@ public:
PathStrokeType::square, PathStrokeType::square,
PathStrokeType::rounded }; 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->setStrokeType (PathStrokeType (listener.owner->getStrokeType().stroke.getStrokeThickness(),
listener.owner->getStrokeType().stroke.getJointStyle(), listener.owner->getStrokeType().stroke.getJointStyle(),

View file

@ -89,6 +89,12 @@ public:
//============================================================================== //==============================================================================
void setFillType (Graphics& g, JucerDocument* const document, const Rectangle<int>& parentArea) void setFillType (Graphics& g, JucerDocument* const document, const Rectangle<int>& parentArea)
{ {
if (document == nullptr)
{
jassertfalse;
return;
}
if (mode == solidColour) if (mode == solidColour)
{ {
image = Image(); image = Image();
@ -96,7 +102,6 @@ public:
} }
else if (mode == imageBrush) else if (mode == imageBrush)
{ {
jassert (document != nullptr);
loadImage (document); loadImage (document);
Rectangle<int> r (imageAnchor.getRectangle (parentArea, document->getComponentLayout())); Rectangle<int> r (imageAnchor.getRectangle (parentArea, document->getComponentLayout()));

View file

@ -584,7 +584,7 @@ void PaintElement::applyBoundsToComponent (Component&, Rectangle<int> newBounds)
{ {
for (auto selectedElement : owner->getSelectedElements()) for (auto selectedElement : owner->getSelectedElements())
{ {
if (selectedElement != this) if (selectedElement != nullptr && selectedElement != this)
{ {
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (selectedElement->getParentComponent())) if (auto* pe = dynamic_cast<PaintRoutineEditor*> (selectedElement->getParentComponent()))
{ {

View file

@ -77,20 +77,21 @@ private:
{ {
showCorrectTab(); showCorrectTab();
PaintElementPath* const path = getElement(); if (auto* const path = getElement())
jassert (path != nullptr); {
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); if (typeChanged)
jassert (p != nullptr); path->pointListChanged();
const bool typeChanged = (p->type != value.type); path->changed();
*p = value; }
p->owner = path; }
if (typeChanged)
path->pointListChanged();
path->changed();
return true; return true;
} }
}; };
@ -849,14 +850,15 @@ public:
{ {
showCorrectTab(); showCorrectTab();
PaintElementPath* const path = getElement(); if (auto* const path = getElement())
jassert (path != nullptr); {
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; return true;
} }
@ -1012,6 +1014,12 @@ bool PaintElementPath::getPoint (int index, int pointNumber, double& x, double&
return false; return false;
} }
if (pointNumber >= PathPoint::maxRects)
{
jassertfalse;
return false;
}
jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo); jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo);
jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo); 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 < 3 || p->type == Path::Iterator::cubicTo);
jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo); jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo);
if (pointNumber >= PathPoint::maxRects)
{
jassertfalse;
return;
}
RelativePositionedRectangle& pr = newPoint.pos [pointNumber]; RelativePositionedRectangle& pr = newPoint.pos [pointNumber];
double x, y, w, h; double x, y, w, h;
@ -1137,6 +1151,12 @@ void PaintElementPath::movePoint (int index, int pointNumber,
RelativePositionedRectangle PaintElementPath::getPoint (int index, int pointNumber) const RelativePositionedRectangle PaintElementPath::getPoint (int index, int pointNumber) const
{ {
if (pointNumber >= PathPoint::maxRects)
{
jassertfalse;
return RelativePositionedRectangle();
}
if (PathPoint* const p = points [index]) if (PathPoint* const p = points [index])
{ {
jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo); 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) 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]) if (PathPoint* const p = points [index])
{ {
PathPoint newPoint (*p); PathPoint newPoint (*p);
@ -1222,17 +1248,17 @@ public:
int getIndex() const override int getIndex() const override
{ {
const PathPoint* const p = owner->getPoint (index); if (const auto* const p = owner->getPoint (index))
jassert (p != nullptr);
switch (p->type)
{ {
case Path::Iterator::startNewSubPath: return 0; switch (p->type)
case Path::Iterator::lineTo: return 1; {
case Path::Iterator::quadraticTo: return 2; case Path::Iterator::startNewSubPath: return 0;
case Path::Iterator::cubicTo: return 3; case Path::Iterator::lineTo: return 1;
case Path::Iterator::closePath: break; case Path::Iterator::quadraticTo: return 2;
default: jassertfalse; break; case Path::Iterator::cubicTo: return 3;
case Path::Iterator::closePath: break;
default: jassertfalse; break;
}
} }
return 0; return 0;

View file

@ -39,9 +39,11 @@ public:
PathPoint& operator= (const PathPoint& other); PathPoint& operator= (const PathPoint& other);
~PathPoint(); ~PathPoint();
static constexpr auto maxRects = 3;
PaintElementPath* owner; PaintElementPath* owner;
Path::Iterator::PathElementType type; Path::Iterator::PathElementType type;
RelativePositionedRectangle pos [3]; RelativePositionedRectangle pos [maxRects];
int getNumPoints() const; int getNumPoints() const;

View file

@ -33,18 +33,22 @@ template <class ElementType>
class PaintElementUndoableAction : public UndoableAction class PaintElementUndoableAction : public UndoableAction
{ {
public: public:
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
PaintElementUndoableAction (ElementType* const element) PaintElementUndoableAction (ElementType* const element)
: routine (*element->getOwner()), : routine (*element->getOwner()),
elementIndex (element->getOwner()->indexOfElement (element)) elementIndex (element->getOwner()->indexOfElement (element))
{ {
jassert (element != nullptr); jassert (element != nullptr);
if (elementIndex < 0) if (element != nullptr && elementIndex < 0)
findGroupIndices (element->getOwner(), element); findGroupIndices (element->getOwner(), element);
jassert (elementIndex >= 0); jassert (elementIndex >= 0);
} }
JUCE_END_IGNORE_WARNINGS_MSVC
ElementType* getElement() const ElementType* getElement() const
{ {
if (containerGroups.size() > 0) if (containerGroups.size() > 0)

View file

@ -572,9 +572,9 @@ PopupMenu ComponentLayout::getRelativeTargetMenu (Component* comp, int whichDime
for (int i = 0; i < components.size(); ++i) 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, m.addItem (menuIdBase + i + 1,
"Relative to " + getComponentMemberVariableName (c) "Relative to " + getComponentMemberVariableName (c)
+ " (class: " + ComponentTypeHandler::getHandlerFor (*c)->getClassName (c) + ")", + " (class: " + ComponentTypeHandler::getHandlerFor (*c)->getClassName (c) + ")",

View file

@ -534,17 +534,19 @@ private:
{ {
for (auto i = concertinaPanel.getNumPanels() - 1; i >= 0; --i) for (auto i = concertinaPanel.getNumPanels() - 1; i >= 0; --i)
{ {
auto* p = concertinaPanel.getPanel (i); if (auto* p = concertinaPanel.getPanel (i))
if (! (p->isParentOf (e.eventComponent)))
{ {
auto* base = dynamic_cast<TreePanelBase*> (p); if (! (p->isParentOf (e.eventComponent)))
{
auto* base = dynamic_cast<TreePanelBase*> (p);
if (base == nullptr) if (base == nullptr)
base = dynamic_cast<ConcertinaTreeComponent*> (p)->getTree(); if (auto* concertina = dynamic_cast<ConcertinaTreeComponent*> (p))
base = concertina->getTree();
if (base != nullptr) if (base != nullptr)
base->tree.clearSelectedItems(); base->tree.clearSelectedItems();
}
} }
} }
} }

View file

@ -468,9 +468,8 @@ public:
if (currentProject != nullptr) if (currentProject != nullptr)
{ {
auto* projectWindow = ProjucerApplication::getApp().mainWindowList.getMainWindowForFile (currentProject->getFile()); if (auto* projectWindow = ProjucerApplication::getApp().mainWindowList.getMainWindowForFile (currentProject->getFile()))
jassert (projectWindow != nullptr); messagesWindow = std::make_unique<MessagesPopupWindow> (*this, *projectWindow, *currentProject);
messagesWindow = std::make_unique<MessagesPopupWindow> (*this, *projectWindow, *currentProject);
auto projectMessagesTree = currentProject->getProjectMessages(); auto projectMessagesTree = currentProject->getProjectMessages();

View file

@ -480,6 +480,7 @@ public:
test (unitTest, true, r); test (unitTest, true, r);
} }
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262)
static void test (UnitTest& unitTest, bool inPlace, Random& r) static void test (UnitTest& unitTest, bool inPlace, Random& r)
{ {
const int numSamples = 2048; const int numSamples = 2048;
@ -537,6 +538,7 @@ public:
unitTest.expect (biggestDiff <= errorMargin); unitTest.expect (biggestDiff <= errorMargin);
} }
} }
JUCE_END_IGNORE_WARNINGS_MSVC
}; };
template <class F1, class E1, class FormatType> template <class F1, class E1, class FormatType>

View file

@ -287,11 +287,14 @@ MidiMessage& MidiMessage::operator= (const MidiMessage& other)
{ {
if (other.isHeapAllocated()) if (other.isHeapAllocated())
{ {
if (isHeapAllocated()) auto* newStorage = static_cast<uint8*> (isHeapAllocated()
packedData.allocatedData = static_cast<uint8*> (std::realloc (packedData.allocatedData, (size_t) other.size)); ? std::realloc (packedData.allocatedData, (size_t) other.size)
else : std::malloc ((size_t) other.size));
packedData.allocatedData = static_cast<uint8*> (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); memcpy (packedData.allocatedData, other.packedData.allocatedData, (size_t) other.size);
} }
else else

View file

@ -833,6 +833,7 @@ public:
testLayout.setUpperZone (6); testLayout.setUpperZone (6);
} }
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262)
void runTest() override void runTest() override
{ {
beginTest ("initial zone layout"); beginTest ("initial zone layout");
@ -2145,6 +2146,7 @@ public:
} }
} }
} }
JUCE_END_IGNORE_WARNINGS_MSVC
private: private:
//============================================================================== //==============================================================================

View file

@ -131,6 +131,7 @@ public:
/** Applies the reverb to two stereo channels of audio data. */ /** Applies the reverb to two stereo channels of audio data. */
void processStereo (float* const left, float* const right, const int numSamples) noexcept void processStereo (float* const left, float* const right, const int numSamples) noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
jassert (left != nullptr && right != nullptr); jassert (left != nullptr && right != nullptr);
for (int i = 0; i < numSamples; ++i) for (int i = 0; i < numSamples; ++i)
@ -160,11 +161,13 @@ public:
left[i] = outL * wet1 + outR * wet2 + left[i] * dry; left[i] = outL * wet1 + outR * wet2 + left[i] * dry;
right[i] = outR * wet1 + outL * wet2 + right[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. */ /** Applies the reverb to a single mono channel of audio data. */
void processMono (float* const samples, const int numSamples) noexcept void processMono (float* const samples, const int numSamples) noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
jassert (samples != nullptr); jassert (samples != nullptr);
for (int i = 0; i < numSamples; ++i) for (int i = 0; i < numSamples; ++i)
@ -186,6 +189,7 @@ public:
samples[i] = output * wet1 + samples[i] * dry; samples[i] = output * wet1 + samples[i] * dry;
} }
JUCE_END_IGNORE_WARNINGS_MSVC
} }
private: private:

View file

@ -857,8 +857,9 @@ void AudioDeviceManager::audioDeviceIOCallbackInt (const float** inputChannelDat
auto* src = testSound->getReadPointer (0, testSoundPosition); auto* src = testSound->getReadPointer (0, testSoundPosition);
for (int i = 0; i < numOutputChannels; ++i) for (int i = 0; i < numOutputChannels; ++i)
for (int j = 0; j < numSamps; ++j) if (auto* dst = outputChannelData [i])
outputChannelData [i][j] += src[j]; for (int j = 0; j < numSamps; ++j)
dst[j] += src[j];
testSoundPosition += numSamps; testSoundPosition += numSamps;

View file

@ -697,7 +697,7 @@ public:
for (const auto typecode : typecodesX1) for (const auto typecode : typecodesX1)
{ {
Packets p; 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); checkMidi2ToMidi1Conversion (p, p);
} }
@ -966,8 +966,10 @@ private:
template <typename Fn> template <typename Fn>
void forEachNonSysExTestMessage (Random& random, Fn&& fn) 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) if (firstByte == 0xf0 || firstByte == 0xf7)
continue; // sysEx is tested separately continue; // sysEx is tested separately

View file

@ -211,12 +211,17 @@ namespace
{ {
if (dsDirectSoundCreate == nullptr) 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) return;
DSOUND_FUNCTION_LOAD (DirectSoundCaptureCreate) }
DSOUND_FUNCTION_LOAD (DirectSoundEnumerateW)
DSOUND_FUNCTION_LOAD (DirectSoundCaptureEnumerateW) jassertfalse;
} }
} }

View file

@ -97,7 +97,7 @@ namespace FlacNamespace
#define FLAC__NO_DLL 1 #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 #if ! JUCE_MSVC
#define HAVE_LROUND 1 #define HAVE_LROUND 1
#endif #endif

View file

@ -2409,6 +2409,7 @@ private:
return numBits; return numBits;
} }
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6385)
int getLayer3ScaleFactors2 (int* scf, Layer3SideInfo::Info& granule, const bool iStereo) noexcept int getLayer3ScaleFactors2 (int* scf, Layer3SideInfo::Info& granule, const bool iStereo) noexcept
{ {
static const uint8 scaleTable[3][6][4] = static const uint8 scaleTable[3][6][4] =
@ -2460,6 +2461,7 @@ private:
return numBits; return numBits;
} }
JUCE_END_IGNORE_WARNINGS_MSVC
bool layer3DequantizeSample (float xr[32][18], int* scf, Layer3SideInfo::Info& granule, int sampleRate, int part2bits) noexcept 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]; sum += window[12] * b0[12]; sum += window[14] * b0[14];
*out++ = sum; *out++ = sum;
b0 -= 16; window -= 32; b0 -= 16; window -= 32;
window += bo1 << 1; window += (ptrdiff_t) bo1 << 1;
} }
for (int j = 15; j != 0; --j, b0 -= 16, window -= 32) for (int j = 15; j != 0; --j, b0 -= 16, window -= 32)
@ -2976,7 +2978,11 @@ public:
bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
int64 startSampleInFile, int numSamples) override int64 startSampleInFile, int numSamples) override
{ {
jassert (destSamples != nullptr); if (destSamples == nullptr)
{
jassertfalse;
return false;
}
if (currentPosition != startSampleInFile) if (currentPosition != startSampleInFile)
{ {

View file

@ -35,7 +35,7 @@ namespace juce
namespace OggVorbisNamespace namespace OggVorbisNamespace
{ {
#if JUCE_INCLUDE_OGGVORBIS_CODE || ! defined (JUCE_INCLUDE_OGGVORBIS_CODE) #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", JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wconversion",
"-Wshadow", "-Wshadow",

View file

@ -231,6 +231,7 @@ public:
for (int i = 0; i < numDestChannels; ++i) for (int i = 0; i < numDestChannels; ++i)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182)
jassert (destSamples[i] != nullptr); jassert (destSamples[i] != nullptr);
auto srcChan = jmin (i, (int) numChannels - 1); auto srcChan = jmin (i, (int) numChannels - 1);
@ -242,6 +243,7 @@ public:
dst[j] = ((uint32) *src) << 16; dst[j] = ((uint32) *src) << 16;
src += numChannels; src += numChannels;
} }
JUCE_END_IGNORE_WARNINGS_MSVC
} }
startSampleInFile += numToDo; startSampleInFile += numToDo;
@ -260,7 +262,7 @@ private:
void checkCoInitialiseCalled() void checkCoInitialiseCalled()
{ {
CoInitialize (0); ignoreUnused (CoInitialize (0));
} }
void scanFileForDetails() void scanFileForDetails()

View file

@ -175,8 +175,12 @@ void AudioFormatReader::read (AudioBuffer<float>* buffer,
read (chans, 2, readerStartSample, numSamples, true); read (chans, 2, readerStartSample, numSamples, true);
// if the target's stereo and the source is mono, dupe the first channel.. // 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)); memcpy (dests[1], dests[0], (size_t) numSamples * sizeof (float));
}
if (! usesFloatingPointData) if (! usesFloatingPointData)
convertFixedToFloat (dests, 2, numSamples); convertFixedToFloat (dests, 2, numSamples);

View file

@ -306,7 +306,12 @@ protected:
int startOffsetInDestBuffer, int64 startSampleInFile, int startOffsetInDestBuffer, int64 startSampleInFile,
int& numSamples, int64 fileLengthInSamples) int& numSamples, int64 fileLengthInSamples)
{ {
jassert (destChannels != nullptr); if (destChannels == nullptr)
{
jassertfalse;
return;
}
const int64 samplesAvailable = fileLengthInSamples - startSampleInFile; const int64 samplesAvailable = fileLengthInSamples - startSampleInFile;
if (samplesAvailable < numSamples) if (samplesAvailable < numSamples)

View file

@ -157,16 +157,16 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int
if (isFloatingPoint()) if (isFloatingPoint())
return write ((const int**) channels, numSamples); return write ((const int**) channels, numSamples);
int* chans[256]; std::vector<int*> chans (256);
int scratch[4096]; std::vector<int> scratch (4096);
jassert (numSourceChannels < numElementsInArray (chans)); jassert (numSourceChannels < (int) chans.size());
const int maxSamples = (int) (numElementsInArray (scratch) / numSourceChannels); const int maxSamples = (int) scratch.size() / numSourceChannels;
for (int i = 0; i < numSourceChannels; ++i) 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; int startSample = 0;
while (numSamples > 0) while (numSamples > 0)
@ -174,9 +174,9 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int
auto numToDo = jmin (numSamples, maxSamples); auto numToDo = jmin (numSamples, maxSamples);
for (int i = 0; i < numSourceChannels; ++i) 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; return false;
startSample += numToDo; startSample += numToDo;

View file

@ -1929,7 +1929,9 @@ private:
pointer_sized_int handleKeyboardFocusRequired (VstOpCodeArguments) pointer_sized_int handleKeyboardFocusRequired (VstOpCodeArguments)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6326)
return (JucePlugin_EditorRequiresKeyboardFocus != 0) ? 1 : 0; return (JucePlugin_EditorRequiresKeyboardFocus != 0) ? 1 : 0;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
pointer_sized_int handleGetVstInterfaceVersion (VstOpCodeArguments) pointer_sized_int handleGetVstInterfaceVersion (VstOpCodeArguments)

View file

@ -527,7 +527,11 @@ private:
{ {
// we need to remain backward compatible with the old bypass id // we need to remain backward compatible with the old bypass id
if (vst3WrapperProvidedBypassParam) if (vst3WrapperProvidedBypassParam)
{
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6240)
vstParamID = static_cast<Vst::ParamID> ((isUsingManagedParameters() && ! forceLegacyParamIDs) ? paramBypass : numParameters); vstParamID = static_cast<Vst::ParamID> ((isUsingManagedParameters() && ! forceLegacyParamIDs) ? paramBypass : numParameters);
JUCE_END_IGNORE_WARNINGS_MSVC
}
bypassParamID = vstParamID; bypassParamID = vstParamID;
} }
@ -3683,18 +3687,15 @@ using namespace juce;
//============================================================================== //==============================================================================
// The VST3 plugin entry point. // 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; 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 // Cunning trick to force this function to be exported. Life's too short to
// faff around creating .def files for this kind of thing. // faff around creating .def files for this kind of thing.
#if JUCE_32BIT // Unnecessary for 64-bit builds because those don't use decorated function names.
#pragma comment(linker, "/EXPORT:GetPluginFactory=_GetPluginFactory@0") #pragma comment(linker, "/EXPORT:GetPluginFactory=_GetPluginFactory@0")
#else
#pragma comment(linker, "/EXPORT:GetPluginFactory=GetPluginFactory")
#endif
#endif #endif
if (globalFactory == nullptr) if (globalFactory == nullptr)

View file

@ -101,16 +101,18 @@ public:
static String getParamID (AudioProcessorParameter* param, bool forceLegacyParamIDs) noexcept static String getParamID (AudioProcessorParameter* param, bool forceLegacyParamIDs) noexcept
{ {
if (auto* legacy = dynamic_cast<LegacyAudioParameter*> (param)) if (auto* legacy = dynamic_cast<LegacyAudioParameter*> (param))
{
return forceLegacyParamIDs ? String (legacy->parameterIndex) : legacy->getParamID(); return forceLegacyParamIDs ? String (legacy->parameterIndex) : legacy->getParamID();
}
else if (auto* paramWithID = dynamic_cast<AudioProcessorParameterWithID*> (param)) if (auto* paramWithID = dynamic_cast<AudioProcessorParameterWithID*> (param))
{ {
if (! forceLegacyParamIDs) if (! forceLegacyParamIDs)
return paramWithID->paramID; return paramWithID->paramID;
} }
return String (param->getParameterIndex()); if (param != nullptr)
return String (param->getParameterIndex());
return {};
} }
}; };

View file

@ -28,7 +28,7 @@
#endif #endif
// Wow, those Steinberg guys really don't worry too much about compiler warnings. // 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", JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wnon-virtual-dtor",
"-Wreorder", "-Wreorder",

View file

@ -175,11 +175,16 @@ private:
static Vst2::VstEvent* allocateVSTEvent() static Vst2::VstEvent* allocateVSTEvent()
{ {
auto e = (Vst2::VstEvent*) std::calloc (1, sizeof (Vst2::VstMidiEvent) > sizeof (Vst2::VstMidiSysexEvent) ? sizeof (Vst2::VstMidiEvent) constexpr auto size = jmax (sizeof (Vst2::VstMidiEvent), sizeof (Vst2::VstMidiSysexEvent));
: sizeof (Vst2::VstMidiSysexEvent));
e->type = Vst2::kVstMidiType; if (auto* e = static_cast<Vst2::VstEvent*> (std::calloc (1, size)))
e->byteSize = sizeof (Vst2::VstMidiEvent); {
return e; e->type = Vst2::kVstMidiType;
e->byteSize = sizeof (Vst2::VstMidiEvent);
return e;
}
return nullptr;
} }
static void freeVSTEvent (Vst2::VstEvent* e) static void freeVSTEvent (Vst2::VstEvent* e)

View file

@ -131,7 +131,7 @@ Array<const AudioProcessorParameterGroup*> AudioProcessorParameterGroup::getGrou
if (auto* group = getGroupForParameter (parameter)) if (auto* group = getGroupForParameter (parameter))
{ {
while (group != this) while (group != nullptr && group != this)
{ {
groups.insert (0, group); groups.insert (0, group);
group = group->getParent(); group = group->getParent();

View file

@ -518,6 +518,7 @@ struct GenericAudioProcessorEditor::Pimpl
{ {
Pimpl (GenericAudioProcessorEditor& parent) : owner (parent) Pimpl (GenericAudioProcessorEditor& parent) : owner (parent)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
auto* p = parent.getAudioProcessor(); auto* p = parent.getAudioProcessor();
jassert (p != nullptr); jassert (p != nullptr);
@ -529,6 +530,7 @@ struct GenericAudioProcessorEditor::Pimpl
owner.addAndMakeVisible (view); owner.addAndMakeVisible (view);
view.setScrollBarsShown (true, false); view.setScrollBarsShown (true, false);
JUCE_END_IGNORE_WARNINGS_MSVC
} }
~Pimpl() ~Pimpl()

View file

@ -194,7 +194,12 @@ bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier,
for (auto* desc : found) for (auto* desc : found)
{ {
jassert (desc != nullptr); if (desc == nullptr)
{
jassertfalse;
continue;
}
addType (*desc); addType (*desc);
typesFound.add (new PluginDescription (*desc)); typesFound.add (new PluginDescription (*desc));
} }

View file

@ -668,6 +668,7 @@ public:
: UnitTest ("Audio Processor Value Tree State", UnitTestCategories::audioProcessorParameters) : UnitTest ("Audio Processor Value Tree State", UnitTestCategories::audioProcessorParameters)
{} {}
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262)
void runTest() override void runTest() override
{ {
ScopedJuceInitialiser_GUI scopedJuceInitialiser_gui; ScopedJuceInitialiser_GUI scopedJuceInitialiser_gui;
@ -952,6 +953,7 @@ public:
expectEquals (listener.id, String (key)); expectEquals (listener.id, String (key));
} }
} }
JUCE_END_IGNORE_WARNINGS_MSVC
}; };
static AudioProcessorValueTreeStateTests audioProcessorValueTreeStateTests; static AudioProcessorValueTreeStateTests audioProcessorValueTreeStateTests;

View file

@ -34,6 +34,7 @@
#include "juce_box2d.h" #include "juce_box2d.h"
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wconversion", JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wconversion",
"-Wsign-conversion", "-Wsign-conversion",
"-Wfloat-conversion", "-Wfloat-conversion",
@ -101,3 +102,4 @@ using uint32 = juce::uint32;
#include "utils/juce_Box2DRenderer.cpp" #include "utils/juce_Box2DRenderer.cpp"
JUCE_END_IGNORE_WARNINGS_GCC_LIKE JUCE_END_IGNORE_WARNINGS_GCC_LIKE
JUCE_END_IGNORE_WARNINGS_MSVC

View file

@ -215,6 +215,8 @@ public:
Random random; Random random;
}; };
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6262)
void runTest() override void runTest() override
{ {
beginTest ("AbstractFifo"); beginTest ("AbstractFifo");
@ -258,6 +260,8 @@ public:
} }
} }
} }
JUCE_END_IGNORE_WARNINGS_MSVC
}; };
static AbstractFifoTests fifoUnitTests; static AbstractFifoTests fifoUnitTests;

View file

@ -179,10 +179,12 @@ public:
*/ */
void insertNext (ObjectType* const newItem) void insertNext (ObjectType* const newItem)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
jassert (newItem != nullptr); jassert (newItem != nullptr);
jassert (newItem->nextListItem == nullptr); jassert (newItem->nextListItem == nullptr);
newItem->nextListItem = item; newItem->nextListItem = item;
item = newItem; item = newItem;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
/** Inserts an item at a numeric index in the list. /** Inserts an item at a numeric index in the list.
@ -208,6 +210,7 @@ public:
*/ */
ObjectType* replaceNext (ObjectType* const newItem) noexcept ObjectType* replaceNext (ObjectType* const newItem) noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011 28182)
jassert (newItem != nullptr); jassert (newItem != nullptr);
jassert (newItem->nextListItem == nullptr); jassert (newItem->nextListItem == nullptr);
@ -216,6 +219,7 @@ public:
item->nextListItem = oldItem->nextListItem.item; item->nextListItem = oldItem->nextListItem.item;
oldItem->nextListItem.item = nullptr; oldItem->nextListItem.item = nullptr;
return oldItem; return oldItem;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
/** Adds an item to the end of the list. /** Adds an item to the end of the list.
@ -308,10 +312,13 @@ public:
*/ */
void copyToArray (ObjectType** destArray) const noexcept void copyToArray (ObjectType** destArray) const noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
jassert (destArray != nullptr); jassert (destArray != nullptr);
for (auto* i = item; i != nullptr; i = i->nextListItem) for (auto* i = item; i != nullptr; i = i->nextListItem)
*destArray++ = i; *destArray++ = i;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
/** Swaps this pointer with another one */ /** Swaps this pointer with another one */

View file

@ -57,7 +57,9 @@ static struct OwnedArrayTest : public UnitTest
{ {
parent.expect (o != nullptr); parent.expect (o != nullptr);
parent.expect (o != this); parent.expect (o != this);
parent.expectEquals (o->data, 956);
if (o != nullptr)
parent.expectEquals (o->data, 956);
} }
} }

View file

@ -158,7 +158,9 @@ private:
{ {
parent.expect (o != nullptr); parent.expect (o != nullptr);
parent.expect (o != this); parent.expect (o != this);
parent.expectEquals (o->data, 374);
if (o != nullptr)
parent.expectEquals (o->data, 374);
} }
} }

View file

@ -571,7 +571,11 @@ struct Expression::Helpers
static Constant* findTermToAdjust (Term* const term, const bool mustBeFlagged) static Constant* findTermToAdjust (Term* const term, const bool mustBeFlagged)
{ {
jassert (term != nullptr); if (term == nullptr)
{
jassertfalse;
return nullptr;
}
if (term->getType() == constantType) if (term->getType() == constantType)
{ {

View file

@ -717,7 +717,7 @@ static String readWindowsLnkFile (File lnkFile, bool wantsAbsolutePath)
&& SUCCEEDED (persistFile->Load (lnkFile.getFullPathName().toWideCharPointer(), STGM_READ)) && SUCCEEDED (persistFile->Load (lnkFile.getFullPathName().toWideCharPointer(), STGM_READ))
&& (! wantsAbsolutePath || SUCCEEDED (shellLink->Resolve (nullptr, SLR_ANY_MATCH | SLR_NO_UI)))) && (! wantsAbsolutePath || SUCCEEDED (shellLink->Resolve (nullptr, SLR_ANY_MATCH | SLR_NO_UI))))
{ {
WIN32_FIND_DATA winFindData; WIN32_FIND_DATA winFindData = {};
WCHAR resolvedPath[MAX_PATH]; WCHAR resolvedPath[MAX_PATH];
DWORD flags = SLGP_UNCPRIORITY; DWORD flags = SLGP_UNCPRIORITY;
@ -861,7 +861,7 @@ bool File::createShortcut (const String& description, const File& linkFileToCrea
ComSmartPtr<IShellLink> shellLink; ComSmartPtr<IShellLink> shellLink;
ComSmartPtr<IPersistFile> persistFile; ComSmartPtr<IPersistFile> persistFile;
CoInitialize (nullptr); ignoreUnused (CoInitialize (nullptr));
return SUCCEEDED (shellLink.CoCreateInstance (CLSID_ShellLink)) return SUCCEEDED (shellLink.CoCreateInstance (CLSID_ShellLink))
&& SUCCEEDED (shellLink->SetPath (getFullPathName().toWideCharPointer())) && SUCCEEDED (shellLink->SetPath (getFullPathName().toWideCharPointer()))

View file

@ -177,7 +177,14 @@ public:
int read (void* buffer, int bytesToRead) int read (void* buffer, int bytesToRead)
{ {
jassert (buffer != nullptr && bytesToRead >= 0); jassert (bytesToRead >= 0);
if (buffer == nullptr)
{
jassertfalse;
return 0;
}
DWORD bytesRead = 0; DWORD bytesRead = 0;
if (! (finished || isError())) if (! (finished || isError()))

View file

@ -28,8 +28,12 @@ HWND juce_messageWindowHandle = nullptr; // (this is used by other parts of the
void* getUser32Function (const char* functionName) void* getUser32Function (const char* functionName)
{ {
HMODULE module = GetModuleHandleA ("user32.dll"); 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 #if JUCE_DEBUG
OutputDebugStringA ("** Warning - Forced thread termination **\n"); OutputDebugStringA ("** Warning - Forced thread termination **\n");
#endif #endif
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6258)
TerminateThread (threadHandle.get(), 0); 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); 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 #else
ignoreUnused (name); ignoreUnused (name);
#endif #endif
@ -404,9 +414,11 @@ public:
startupInfo.hStdError = (streamFlags & wantStdErr) != 0 ? writePipe : nullptr; startupInfo.hStdError = (streamFlags & wantStdErr) != 0 ? writePipe : nullptr;
startupInfo.dwFlags = STARTF_USESTDHANDLES; startupInfo.dwFlags = STARTF_USESTDHANDLES;
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6335)
ok = CreateProcess (nullptr, const_cast<LPWSTR> (command.toWideCharPointer()), ok = CreateProcess (nullptr, const_cast<LPWSTR> (command.toWideCharPointer()),
nullptr, nullptr, TRUE, CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT, nullptr, nullptr, TRUE, CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT,
nullptr, nullptr, &startupInfo, &processInfo) != FALSE; nullptr, nullptr, &startupInfo, &processInfo) != FALSE;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
} }

View file

@ -58,11 +58,9 @@ namespace SocketHelpers
if (! socketsStarted) if (! socketsStarted)
{ {
socketsStarted = true;
WSADATA wsaData; WSADATA wsaData;
const WORD wVersionRequested = MAKEWORD (1, 1); const WORD wVersionRequested = MAKEWORD (1, 1);
WSAStartup (wVersionRequested, &wsaData); socketsStarted = WSAStartup (wVersionRequested, &wsaData) == 0;
} }
#endif #endif
} }

View file

@ -486,11 +486,13 @@ public:
*/ */
static bool isByteOrderMarkBigEndian (const void* possibleByteOrder) noexcept static bool isByteOrderMarkBigEndian (const void* possibleByteOrder) noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182)
jassert (possibleByteOrder != nullptr); jassert (possibleByteOrder != nullptr);
auto c = static_cast<const uint8*> (possibleByteOrder); auto c = static_cast<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMarkBE1 return c[0] == (uint8) byteOrderMarkBE1
&& c[1] == (uint8) byteOrderMarkBE2; && 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). /** 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 static bool isByteOrderMarkLittleEndian (const void* possibleByteOrder) noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182)
jassert (possibleByteOrder != nullptr); jassert (possibleByteOrder != nullptr);
auto c = static_cast<const uint8*> (possibleByteOrder); auto c = static_cast<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMarkLE1 return c[0] == (uint8) byteOrderMarkLE1
&& c[1] == (uint8) byteOrderMarkLE2; && c[1] == (uint8) byteOrderMarkLE2;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
private: private:

View file

@ -274,8 +274,10 @@ public:
*/ */
size_t sizeInBytes() const noexcept size_t sizeInBytes() const noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6387)
jassert (data != nullptr); jassert (data != nullptr);
return strlen (data) + 1; return strlen (data) + 1;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
/** Returns the number of bytes that would be needed to represent the given /** 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 static bool isByteOrderMark (const void* possibleByteOrder) noexcept
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (28182)
jassert (possibleByteOrder != nullptr); jassert (possibleByteOrder != nullptr);
auto c = static_cast<const uint8*> (possibleByteOrder); auto c = static_cast<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMark1 return c[0] == (uint8) byteOrderMark1
&& c[1] == (uint8) byteOrderMark2 && c[1] == (uint8) byteOrderMark2
&& c[2] == (uint8) byteOrderMark3; && c[2] == (uint8) byteOrderMark3;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
private: private:

View file

@ -116,7 +116,10 @@ struct TextDiffHelpers
if (scratchSpace < 4096) if (scratchSpace < 4096)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255)
auto* scratch = (int*) alloca (scratchSpace); auto* scratch = (int*) alloca (scratchSpace);
JUCE_END_IGNORE_WARNINGS_MSVC
return findLongestCommonSubstring (a, lenA, indexInA, b, lenB, indexInB, scratchSpace, scratch); return findLongestCommonSubstring (a, lenA, indexInA, b, lenB, indexInB, scratchSpace, scratch);
} }

View file

@ -108,7 +108,7 @@ TimeSliceClient* TimeSliceThread::getNextClient (int index) const
{ {
auto* c = clients.getUnchecked ((i + index) % clients.size()); auto* c = clients.getUnchecked ((i + index) % clients.size());
if (client == nullptr || c->nextCallTime < soonest) if (c != nullptr && (client == nullptr || c->nextCallTime < soonest))
{ {
client = c; client = c;
soonest = c->nextCallTime; soonest = c->nextCallTime;

View file

@ -23,7 +23,7 @@
namespace juce namespace juce
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4309 4305 4365) JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4309 4305 4365 6385 6326 6340)
namespace zlibNamespace namespace zlibNamespace
{ {

View file

@ -949,19 +949,16 @@ void ValueTree::moveChild (int currentIndex, int newIndex, UndoManager* undoMana
//============================================================================== //==============================================================================
void ValueTree::createListOfChildren (OwnedArray<ValueTree>& list) const void ValueTree::createListOfChildren (OwnedArray<ValueTree>& list) const
{ {
jassert (object != nullptr); if (object != nullptr)
for (auto* o : object->children)
for (auto* o : object->children) if (o != nullptr)
{ list.add (new ValueTree (*o));
jassert (o != nullptr);
list.add (new ValueTree (*o));
}
} }
void ValueTree::reorderChildren (const OwnedArray<ValueTree>& newOrder, UndoManager* undoManager) void ValueTree::reorderChildren (const OwnedArray<ValueTree>& newOrder, UndoManager* undoManager)
{ {
jassert (object != nullptr); if (object != nullptr)
object->reorderChildren (newOrder, undoManager); object->reorderChildren (newOrder, undoManager);
} }
//============================================================================== //==============================================================================

View file

@ -135,7 +135,9 @@ struct FFTFallback : public FFT::Instance
if (scratchSize < maxFFTScratchSpaceToAlloca) if (scratchSize < maxFFTScratchSpaceToAlloca)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255)
performRealOnlyForwardTransform (static_cast<Complex<float>*> (alloca (scratchSize)), d); performRealOnlyForwardTransform (static_cast<Complex<float>*> (alloca (scratchSize)), d);
JUCE_END_IGNORE_WARNINGS_MSVC
} }
else else
{ {
@ -153,7 +155,9 @@ struct FFTFallback : public FFT::Instance
if (scratchSize < maxFFTScratchSpaceToAlloca) if (scratchSize < maxFFTScratchSpaceToAlloca)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255)
performRealOnlyInverseTransform (static_cast<Complex<float>*> (alloca (scratchSize)), d); performRealOnlyInverseTransform (static_cast<Complex<float>*> (alloca (scratchSize)), d);
JUCE_END_IGNORE_WARNINGS_MSVC
} }
else else
{ {
@ -315,13 +319,17 @@ struct FFTFallback : public FFT::Instance
default: jassertfalse; break; default: jassertfalse; break;
} }
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255)
auto* scratch = static_cast<Complex<float>*> (alloca ((size_t) factor.radix * sizeof (Complex<float>))); auto* scratch = static_cast<Complex<float>*> (alloca ((size_t) factor.radix * sizeof (Complex<float>)));
JUCE_END_IGNORE_WARNINGS_MSVC
for (int i = 0; i < factor.length; ++i) for (int i = 0; i < factor.length; ++i)
{ {
for (int k = i, q1 = 0; q1 < factor.radix; ++q1) for (int k = i, q1 = 0; q1 < factor.radix; ++q1)
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6386)
scratch[q1] = data[k]; scratch[q1] = data[k];
JUCE_END_IGNORE_WARNINGS_MSVC
k += factor.length; k += factor.length;
} }
@ -337,7 +345,9 @@ struct FFTFallback : public FFT::Instance
if (twiddleIndex >= fftSize) if (twiddleIndex >= fftSize)
twiddleIndex -= fftSize; twiddleIndex -= fftSize;
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6385)
data[k] += scratch[q] * twiddleTable[twiddleIndex]; data[k] += scratch[q] * twiddleTable[twiddleIndex];
JUCE_END_IGNORE_WARNINGS_MSVC
} }
k += factor.length; k += factor.length;

View file

@ -148,7 +148,7 @@ struct FFTUnitTest : public UnitTest
HeapBlock<Complex<float>> frequency (n); HeapBlock<Complex<float>> frequency (n);
fillRandom (random, inout.getData(), 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); performReferenceFourier (inout.getData(), frequency.getData(), n, false);
for (size_t i = 0; i < n; ++i) for (size_t i = 0; i < n; ++i)

View file

@ -128,6 +128,7 @@ public:
} }
else else
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6386)
auto* biases = static_cast<FloatType*> (alloca (sizeof (FloatType) * len)); auto* biases = static_cast<FloatType*> (alloca (sizeof (FloatType) * len));
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
@ -137,6 +138,7 @@ public:
FloatVectorOperations::add (outBlock.getChannelPointer (chan), FloatVectorOperations::add (outBlock.getChannelPointer (chan),
inBlock.getChannelPointer (chan), inBlock.getChannelPointer (chan),
biases, static_cast<int> (len)); biases, static_cast<int> (len));
JUCE_END_IGNORE_WARNINGS_MSVC
} }
} }

View file

@ -124,10 +124,12 @@ public:
} }
else else
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6386)
auto* gains = static_cast<FloatType*> (alloca (sizeof (FloatType) * len)); auto* gains = static_cast<FloatType*> (alloca (sizeof (FloatType) * len));
for (size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
gains[i] = gain.getNextValue(); gains[i] = gain.getNextValue();
JUCE_END_IGNORE_WARNINGS_MSVC
for (size_t chan = 0; chan < numChannels; ++chan) for (size_t chan = 0; chan < numChannels; ++chan)
FloatVectorOperations::multiply (outBlock.getChannelPointer (chan), FloatVectorOperations::multiply (outBlock.getChannelPointer (chan),

View file

@ -88,7 +88,10 @@ public:
#define START_JUCE_APPLICATION(AppClass) #define START_JUCE_APPLICATION(AppClass)
#else #else
#if JUCE_WINDOWS && ! defined (_CONSOLE) #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 #define JUCE_MAIN_FUNCTION_ARGS
#else #else
#define JUCE_MAIN_FUNCTION int main (int argc, char* argv[]) #define JUCE_MAIN_FUNCTION int main (int argc, char* argv[])

View file

@ -288,7 +288,7 @@ void MessageManager::broadcastMessage (const String& value)
//============================================================================== //==============================================================================
void MessageManager::doPlatformSpecificInitialisation() void MessageManager::doPlatformSpecificInitialisation()
{ {
OleInitialize (nullptr); ignoreUnused (OleInitialize (nullptr));
InternalMessageQueue::getInstance(); InternalMessageQueue::getInstance();
} }

View file

@ -26,6 +26,8 @@
namespace juce namespace juce
{ {
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6263 6386)
const int juce_edgeTableDefaultEdgesPerLine = 32; const int juce_edgeTableDefaultEdgesPerLine = 32;
//============================================================================== //==============================================================================
@ -838,4 +840,6 @@ bool EdgeTable::isEmpty() noexcept
return bounds.getHeight() == 0; return bounds.getHeight() == 0;
} }
JUCE_END_IGNORE_WARNINGS_MSVC
} // namespace juce } // namespace juce

View file

@ -30,6 +30,8 @@ namespace juce
Image juce_loadWithCoreImage (InputStream& input); Image juce_loadWithCoreImage (InputStream& input);
#else #else
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6385)
//============================================================================== //==============================================================================
class GIFLoader class GIFLoader
{ {
@ -113,7 +115,8 @@ private:
bool getSizeFromHeader (int& w, int& h) 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 if (input.read (b, 6) == 6
&& (strncmp ("GIF87a", b, 6) == 0 && (strncmp ("GIF87a", b, 6) == 0
@ -412,6 +415,8 @@ private:
JUCE_DECLARE_NON_COPYABLE (GIFLoader) JUCE_DECLARE_NON_COPYABLE (GIFLoader)
}; };
JUCE_END_IGNORE_WARNINGS_MSVC
#endif #endif
//============================================================================== //==============================================================================

View file

@ -26,7 +26,7 @@
namespace juce 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 namespace jpeglibNamespace
{ {

View file

@ -26,7 +26,7 @@
namespace juce 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 namespace zlibNamespace
{ {

View file

@ -430,19 +430,19 @@ namespace GradientPixelIterators
if (vertical) 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); start = roundToInt (p1.y * (float) scale);
} }
else if (horizontal) 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); start = roundToInt (p1.x * (float) scale);
} }
else else
{ {
grad = (p2.getY() - p1.y) / (double) (p1.x - p2.x); grad = (p2.getY() - p1.y) / (double) (p1.x - p2.x);
yTerm = p1.getY() - p1.x / grad; 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; grad *= scale;
} }
} }

View file

@ -382,7 +382,9 @@ struct Component::ComponentHelpers
if (directParent == parent) if (directParent == parent)
return convertFromParentSpace (target, coordInParent); return convertFromParentSpace (target, coordInParent);
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent)); return convertFromParentSpace (target, convertFromDistantParentSpace (parent, *directParent, coordInParent));
JUCE_END_IGNORE_WARNINGS_MSVC
} }
template <typename PointOrRect> template <typename PointOrRect>
@ -393,9 +395,13 @@ struct Component::ComponentHelpers
if (source == target) if (source == target)
return p; return p;
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
if (source->isParentOf (target)) if (source->isParentOf (target))
return convertFromDistantParentSpace (source, *target, p); return convertFromDistantParentSpace (source, *target, p);
JUCE_END_IGNORE_WARNINGS_MSVC
p = convertToParentSpace (*source, p); p = convertToParentSpace (*source, p);
source = source->getParentComponent(); source = source->getParentComponent();
} }
@ -3014,7 +3020,7 @@ bool Component::isMouseOver (bool includeChildren) const
{ {
auto* c = ms.getComponentUnderMouse(); 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 (ms.isDragging() || ! (ms.isTouch() || ms.isPen()))
if (c->reallyContains (c->getLocalPoint (nullptr, ms.getScreenPosition()).roundToInt(), false)) if (c->reallyContains (c->getLocalPoint (nullptr, ms.getScreenPosition()).roundToInt(), false))
return true; return true;

View file

@ -348,7 +348,9 @@ void Displays::updateToLogical()
} }
} }
retVal->isRoot = true; if (retVal != nullptr)
retVal->isRoot = true;
return retVal; return retVal;
}(); }();

View file

@ -84,10 +84,8 @@ public:
if (isDirectory) if (isDirectory)
{ {
if (subContentsList == nullptr) if (subContentsList == nullptr && parentContentsList != nullptr)
{ {
jassert (parentContentsList != nullptr);
auto l = new DirectoryContentsList (parentContentsList->getFilter(), thread); auto l = new DirectoryContentsList (parentContentsList->getFilter(), thread);
l->setDirectory (file, l->setDirectory (file,

View file

@ -220,6 +220,13 @@ bool MultiDocumentPanel::addDocument (Component* const component,
bool MultiDocumentPanel::closeDocument (Component* component, bool MultiDocumentPanel::closeDocument (Component* component,
const bool checkItsOkToCloseFirst) 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 (components.contains (component))
{ {
if (checkItsOkToCloseFirst && ! tryToCloseDocument (component)) if (checkItsOkToCloseFirst && ! tryToCloseDocument (component))
@ -304,6 +311,8 @@ bool MultiDocumentPanel::closeDocument (Component* component,
} }
return true; return true;
JUCE_END_IGNORE_WARNINGS_MSVC
} }
int MultiDocumentPanel::getNumDocuments() const noexcept int MultiDocumentPanel::getNumDocuments() const noexcept

View file

@ -1747,6 +1747,9 @@ Button* LookAndFeel_V2::createFilenameComponentBrowseButton (const String& text)
void LookAndFeel_V2::layoutFilenameComponent (FilenameComponent& filenameComp, void LookAndFeel_V2::layoutFilenameComponent (FilenameComponent& filenameComp,
ComboBox* filenameBox, Button* browseButton) ComboBox* filenameBox, Button* browseButton)
{ {
if (browseButton == nullptr || filenameBox == nullptr)
return;
browseButton->setSize (80, filenameComp.getHeight()); browseButton->setSize (80, filenameComp.getHeight());
if (auto* tb = dynamic_cast<TextButton*> (browseButton)) if (auto* tb = dynamic_cast<TextButton*> (browseButton))

View file

@ -113,7 +113,9 @@ namespace DragAndDropHelpers
if (source.ptd != nullptr) if (source.ptd != nullptr)
{ {
dest.ptd = (DVTARGETDEVICE*) CoTaskMemAlloc (sizeof (DVTARGETDEVICE)); 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 src = GlobalLock (medium->hGlobal);
void* const dst = GlobalAlloc (GMEM_FIXED, len); void* const dst = GlobalAlloc (GMEM_FIXED, len);
memcpy (dst, src, len); if (src != nullptr && dst != nullptr)
memcpy (dst, src, len);
GlobalUnlock (medium->hGlobal); GlobalUnlock (medium->hGlobal);
@ -215,11 +218,20 @@ namespace DragAndDropHelpers
for (int i = fileNames.size(); --i >= 0;) for (int i = fileNames.size(); --i >= 0;)
totalBytes += CharPointer_UTF16::getBytesRequiredFor (fileNames[i].getCharPointer()) + sizeof (WCHAR); 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<void, Deleter> ((HDROP) GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (DROPFILES) + totalBytes + 4));
if (hDrop != nullptr) if (hDrop != nullptr)
{ {
auto pDropFiles = (LPDROPFILES) GlobalLock (hDrop); auto pDropFiles = (LPDROPFILES) GlobalLock (hDrop.get());
if (pDropFiles == nullptr)
return nullptr;
pDropFiles->pFiles = sizeof (DROPFILES); pDropFiles->pFiles = sizeof (DROPFILES);
pDropFiles->fWide = true; pDropFiles->fWide = true;
@ -233,10 +245,10 @@ namespace DragAndDropHelpers
*fname = 0; *fname = 0;
GlobalUnlock (hDrop); GlobalUnlock (hDrop.get());
} }
return hDrop; return static_cast<HDROP> (hDrop.release());
} }
struct DragAndDropJob : public ThreadPoolJob struct DragAndDropJob : public ThreadPoolJob
@ -250,10 +262,10 @@ namespace DragAndDropHelpers
JobStatus runJob() override JobStatus runJob() override
{ {
OleInitialize (nullptr); ignoreUnused (OleInitialize (nullptr));
auto source = new JuceDropSource(); auto* source = new JuceDropSource();
auto data = new JuceDataObject (&format, &medium); auto* data = new JuceDataObject (&format, &medium);
DWORD effect; DWORD effect;
DoDragDrop (data, source, whatToDo, &effect); DoDragDrop (data, source, whatToDo, &effect);
@ -332,6 +344,10 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co
auto numBytes = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer()); auto numBytes = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer());
medium.hGlobal = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, numBytes + 2); medium.hGlobal = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, numBytes + 2);
if (medium.hGlobal == nullptr)
return false;
auto* data = static_cast<WCHAR*> (GlobalLock (medium.hGlobal)); auto* data = static_cast<WCHAR*> (GlobalLock (medium.hGlobal));
text.copyToUTF16 (data, numBytes + 2); text.copyToUTF16 (data, numBytes + 2);

View file

@ -507,7 +507,7 @@ private:
struct ScopedCoInitialize struct ScopedCoInitialize
{ {
// IUnknown_GetWindow will only succeed when instantiated in a single-thread apartment // 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(); } ~ScopedCoInitialize() { CoUninitialize(); }
}; };

View file

@ -353,7 +353,7 @@ static void checkForPointerAPI()
//============================================================================== //==============================================================================
using SetProcessDPIAwareFunc = BOOL (WINAPI*) (); using SetProcessDPIAwareFunc = BOOL (WINAPI*) ();
using SetProcessDPIAwarenessContextFunc = BOOL (WINAPI*) (DPI_AWARENESS_CONTEXT); 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 SetThreadDPIAwarenessContextFunc = DPI_AWARENESS_CONTEXT (WINAPI*) (DPI_AWARENESS_CONTEXT);
using GetDPIForWindowFunc = UINT (WINAPI*) (HWND); using GetDPIForWindowFunc = UINT (WINAPI*) (HWND);
using GetDPIForMonitorFunc = HRESULT (WINAPI*) (HMONITOR, Monitor_DPI_Type, UINT*, UINT*); using GetDPIForMonitorFunc = HRESULT (WINAPI*) (HMONITOR, Monitor_DPI_Type, UINT*, UINT*);
@ -406,7 +406,7 @@ static void setDPIAwareness()
setProcessDPIAwarenessContext = (SetProcessDPIAwarenessContextFunc) getUser32Function ("SetProcessDpiAwarenessContext"); setProcessDPIAwarenessContext = (SetProcessDPIAwarenessContextFunc) getUser32Function ("SetProcessDpiAwarenessContext");
if (setProcessDPIAwarenessContext != nullptr if (setProcessDPIAwarenessContext != nullptr
&& SUCCEEDED (setProcessDPIAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2))) && setProcessDPIAwarenessContext (DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2))
return; return;
enableNonClientDPIScaling = (EnableNonClientDPIScalingFunc) getUser32Function ("EnableNonClientDpiScaling"); enableNonClientDPIScaling = (EnableNonClientDPIScalingFunc) getUser32Function ("EnableNonClientDpiScaling");
@ -874,7 +874,8 @@ public:
hBitmap = CreateDIBSection (hdc, (BITMAPINFO*) &(bitmapInfo), DIB_RGB_COLORS, hBitmap = CreateDIBSection (hdc, (BITMAPINFO*) &(bitmapInfo), DIB_RGB_COLORS,
(void**) &bitmapData, nullptr, 0); (void**) &bitmapData, nullptr, 0);
previousBitmap = SelectObject (hdc, hBitmap); if (hBitmap != nullptr)
previousBitmap = SelectObject (hdc, hBitmap);
if (format == Image::ARGB && clearImage) if (format == Image::ARGB && clearImage)
zeromem (bitmapData, (size_t) std::abs (h * lineStride)); zeromem (bitmapData, (size_t) std::abs (h * lineStride));
@ -1030,7 +1031,7 @@ namespace IconConverters
ScopedICONINFO info; ScopedICONINFO info;
if (! SUCCEEDED (::GetIconInfo (icon, &info))) if (! ::GetIconInfo (icon, &info))
return {}; return {};
BITMAP bm; BITMAP bm;
@ -1878,7 +1879,7 @@ public:
{ {
FORMATETC format = { type, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; 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); dataSize = GlobalSize (medium.hGlobal);
data = GlobalLock (medium.hGlobal); data = GlobalLock (medium.hGlobal);
@ -1887,7 +1888,7 @@ public:
~DroppedData() ~DroppedData()
{ {
if (data != nullptr) if (data != nullptr && medium.hGlobal != nullptr)
GlobalUnlock (medium.hGlobal); GlobalUnlock (medium.hGlobal);
} }
@ -3153,7 +3154,7 @@ private:
const UINT keyChar = MapVirtualKey ((UINT) key, 2); const UINT keyChar = MapVirtualKey ((UINT) key, 2);
const UINT scanCode = MapVirtualKey ((UINT) key, 0); const UINT scanCode = MapVirtualKey ((UINT) key, 0);
BYTE keyState[256]; BYTE keyState[256];
GetKeyboardState (keyState); ignoreUnused (GetKeyboardState (keyState));
WCHAR text[16] = { 0 }; WCHAR text[16] = { 0 };
if (ToUnicode ((UINT) key, scanCode, keyState, text, 8, 0) != 1) 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()) if (processID == GetCurrentProcessId())
{ {
WINDOWINFO info; WINDOWINFO info{};
if (GetWindowInfo (hwnd, &info) if (GetWindowInfo (hwnd, &info)
&& (info.dwExStyle & WS_EX_TOPMOST) != 0) && (info.dwExStyle & WS_EX_TOPMOST) != 0)
@ -4642,7 +4643,7 @@ void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable,
if (auto* tlw = dynamic_cast<TopLevelWindow*> (kioskModeComp)) if (auto* tlw = dynamic_cast<TopLevelWindow*> (kioskModeComp))
tlw->setUsingNativeTitleBar (! enableOrDisable); tlw->setUsingNativeTitleBar (! enableOrDisable);
if (enableOrDisable) if (kioskModeComp != nullptr && enableOrDisable)
kioskModeComp->setBounds (getDisplays().getDisplayForRect (kioskModeComp->getScreenBounds())->totalArea); kioskModeComp->setBounds (getDisplays().getDisplayForRect (kioskModeComp->getScreenBounds())->totalArea);
} }

View file

@ -150,7 +150,7 @@ void Label::attachToComponent (Component* owner, bool onLeft)
if (ownerComponent != nullptr) if (ownerComponent != nullptr)
{ {
setVisible (owner->isVisible()); setVisible (ownerComponent->isVisible());
ownerComponent->addComponentListener (this); ownerComponent->addComponentListener (this);
componentParentHierarchyChanged (*ownerComponent); componentParentHierarchyChanged (*ownerComponent);
componentMovedOrResized (*ownerComponent, true, true); componentMovedOrResized (*ownerComponent, true, true);

View file

@ -163,7 +163,7 @@ public:
{ {
auto* tc = bar.items.getUnchecked(i); auto* tc = bar.items.getUnchecked(i);
if (dynamic_cast<Spacer*> (tc) == nullptr && ! tc->isVisible()) if (tc != nullptr && dynamic_cast<Spacer*> (tc) == nullptr && ! tc->isVisible())
{ {
oldIndexes.insert (0, i); oldIndexes.insert (0, i);
addAndMakeVisible (tc, 0); addAndMakeVisible (tc, 0);

View file

@ -506,7 +506,12 @@ private:
if (modifiers.isShiftDown() && ((firstSelected = owner.getSelectedItem (0)) != nullptr)) if (modifiers.isShiftDown() && ((firstSelected = owner.getSelectedItem (0)) != nullptr))
{ {
auto* lastSelected = owner.getSelectedItem (owner.getNumSelectedItems() - 1); auto* lastSelected = owner.getSelectedItem (owner.getNumSelectedItems() - 1);
jassert (lastSelected != nullptr);
if (lastSelected == nullptr)
{
jassertfalse;
return;
}
auto rowStart = firstSelected->getRowNumberInTree(); auto rowStart = firstSelected->getRowNumberInTree();
auto rowEnd = lastSelected->getRowNumberInTree(); auto rowEnd = lastSelected->getRowNumberInTree();

View file

@ -108,7 +108,7 @@ void TooltipWindow::displayTip (Point<int> screenPos, const String& tip)
for (auto* w : activeTooltipWindows) 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.. // 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 // Be careful not to create more than one instance of this class with the

View file

@ -96,12 +96,12 @@ public:
if (connectionPoint != nullptr) if (connectionPoint != nullptr)
{ {
auto* owner = dynamic_cast<WebBrowserComponent*> (Component::getParentComponent()); if (auto* owner = dynamic_cast<WebBrowserComponent*> (Component::getParentComponent()))
jassert (owner != nullptr); {
auto handler = new EventHandler (*owner);
auto handler = new EventHandler (*owner); connectionPoint->Advise (handler, &adviseCookie);
connectionPoint->Advise (handler, &adviseCookie); handler->Release();
handler->Release(); }
} }
} }
} }

View file

@ -286,7 +286,7 @@ GLuint OpenGLFrameBuffer::getFrameBufferID() const noexcept
GLuint OpenGLFrameBuffer::getCurrentFrameBufferTarget() noexcept GLuint OpenGLFrameBuffer::getCurrentFrameBufferTarget() noexcept
{ {
GLint fb; GLint fb = {};
glGetIntegerv (GL_FRAMEBUFFER_BINDING, &fb); glGetIntegerv (GL_FRAMEBUFFER_BINDING, &fb);
return (GLuint) fb; return (GLuint) fb;
} }

View file

@ -108,9 +108,12 @@ struct CachedImageList : public ReferenceCountedObject,
TextureInfo getTextureInfo() TextureInfo getTextureInfo()
{ {
if (pixelData == nullptr)
return {};
TextureInfo t; TextureInfo t;
if (textureNeedsReloading && pixelData != nullptr) if (textureNeedsReloading)
{ {
textureNeedsReloading = false; textureNeedsReloading = false;
texture.loadImage (Image (*pixelData)); texture.loadImage (Image (*pixelData));
@ -1049,7 +1052,11 @@ struct StateHelpers
void bindTexture (GLuint textureID) noexcept void bindTexture (GLuint textureID) noexcept
{ {
jassert (currentActiveTexture >= 0); if (currentActiveTexture < 0 || numTextures <= currentActiveTexture)
{
jassertfalse;
return;
}
if (currentTextureID[currentActiveTexture] != textureID) if (currentTextureID[currentActiveTexture] != textureID)
{ {
@ -1068,7 +1075,8 @@ struct StateHelpers
} }
private: private:
GLuint currentTextureID[3]; static constexpr auto numTextures = 3;
GLuint currentTextureID[numTextures];
int texturesEnabled = 0, currentActiveTexture = -1; int texturesEnabled = 0, currentActiveTexture = -1;
const OpenGLContext& context; const OpenGLContext& context;

View file

@ -77,10 +77,10 @@ bool OpenGLShaderProgram::addShader (const String& code, GLenum type)
if (status == (GLint) GL_FALSE) if (status == (GLint) GL_FALSE)
{ {
GLchar infoLog [16384]; std::vector<GLchar> infoLog (16384);
GLsizei infoLogLength = 0; GLsizei infoLogLength = 0;
context.extensions.glGetShaderInfoLog (shaderID, sizeof (infoLog), &infoLogLength, infoLog); context.extensions.glGetShaderInfoLog (shaderID, (GLsizei) infoLog.size(), &infoLogLength, infoLog.data());
errorLog = String (infoLog, (size_t) infoLogLength); errorLog = String (infoLog.data(), (size_t) infoLogLength);
#if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR #if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR
// Your GLSL code contained compile errors! // Your GLSL code contained compile errors!
@ -115,10 +115,10 @@ bool OpenGLShaderProgram::link() noexcept
if (status == (GLint) GL_FALSE) if (status == (GLint) GL_FALSE)
{ {
GLchar infoLog [16384]; std::vector<GLchar> infoLog (16384);
GLsizei infoLogLength = 0; GLsizei infoLogLength = 0;
context.extensions.glGetProgramInfoLog (progID, sizeof (infoLog), &infoLogLength, infoLog); context.extensions.glGetProgramInfoLog (progID, (GLsizei) infoLog.size(), &infoLogLength, infoLog.data());
errorLog = String (infoLog, (size_t) infoLogLength); errorLog = String (infoLog.data(), (size_t) infoLogLength);
#if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR #if JUCE_DEBUG && ! JUCE_DONT_ASSERT_ON_GLSL_COMPILE_ERROR
// Your GLSL code contained link errors! // Your GLSL code contained link errors!

View file

@ -461,7 +461,7 @@ public:
{ {
// string: // string:
expect (testString.length() % 4 != 0); // check whether we actually cover padding 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); OSCArgument arg (testString);
OSCOutputStream outStream; OSCOutputStream outStream;
@ -474,7 +474,7 @@ public:
{ {
// blob: // blob:
expect (testBlob.getSize() % 4 != 0); // check whether we actually cover padding 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); OSCArgument arg (testBlob);
OSCOutputStream outStream; OSCOutputStream outStream;

View file

@ -139,9 +139,12 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster
AM_MEDIA_TYPE mt = {}; AM_MEDIA_TYPE mt = {};
hr = sampleGrabber->GetConnectedMediaType (&mt); hr = sampleGrabber->GetConnectedMediaType (&mt);
VIDEOINFOHEADER* pVih = (VIDEOINFOHEADER*) (mt.pbFormat);
width = pVih->bmiHeader.biWidth; if (auto* pVih = (VIDEOINFOHEADER*) (mt.pbFormat))
height = pVih->bmiHeader.biHeight; {
width = pVih->bmiHeader.biWidth;
height = pVih->bmiHeader.biHeight;
}
ComSmartPtr<IBaseFilter> nullFilter; ComSmartPtr<IBaseFilter> nullFilter;
hr = nullFilter.CoCreateInstance (CLSID_NullRenderer); hr = nullFilter.CoCreateInstance (CLSID_NullRenderer);
@ -465,6 +468,13 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster
int index = 0; int index = 0;
ComSmartPtr<ICreateDevEnum> pDevEnum; ComSmartPtr<ICreateDevEnum> pDevEnum;
struct Deleter
{
void operator() (IUnknown* ptr) const noexcept { ptr->Release(); }
};
using ContextPtr = std::unique_ptr<IBindCtx, Deleter>;
if (SUCCEEDED (pDevEnum.CoCreateInstance (CLSID_SystemDeviceEnum))) if (SUCCEEDED (pDevEnum.CoCreateInstance (CLSID_SystemDeviceEnum)))
{ {
ComSmartPtr<IEnumMoniker> enumerator; ComSmartPtr<IEnumMoniker> enumerator;
@ -477,13 +487,20 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster
while (enumerator->Next (1, moniker.resetAndGetPointerAddress(), &fetched) == S_OK) while (enumerator->Next (1, moniker.resetAndGetPointerAddress(), &fetched) == S_OK)
{ {
auto context = []
{
IBindCtx* ptr = nullptr;
ignoreUnused (CreateBindCtx (0, &ptr));
return ContextPtr (ptr);
}();
ComSmartPtr<IBaseFilter> captureFilter; ComSmartPtr<IBaseFilter> 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)) if (SUCCEEDED (hr))
{ {
ComSmartPtr<IPropertyBag> propertyBag; ComSmartPtr<IPropertyBag> 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)) if (SUCCEEDED (hr))
{ {
@ -719,7 +736,7 @@ private:
return false; return false;
ComSmartPtr<IMoniker> moniker; ComSmartPtr<IMoniker> moniker;
WCHAR buffer[128]; WCHAR buffer[128]{};
HRESULT hr = CreateItemMoniker (_T("!"), buffer, moniker.resetAndGetPointerAddress()); HRESULT hr = CreateItemMoniker (_T("!"), buffer, moniker.resetAndGetPointerAddress());
if (FAILED (hr)) if (FAILED (hr))
return false; return false;

View file

@ -394,7 +394,7 @@ private:
{ {
DirectShowContext (Pimpl& c) : component (c) DirectShowContext (Pimpl& c) : component (c)
{ {
CoInitialize (0); ignoreUnused (CoInitialize (0));
} }
~DirectShowContext() ~DirectShowContext()