1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +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..
for (auto* child : xml.getChildIterator())
{
jassert (child != nullptr);
addSubItem (new XmlTreeItem (*child));
}
if (child != nullptr)
addSubItem (new XmlTreeItem (*child));
}
}
else

View file

@ -41,18 +41,21 @@ public:
XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) override
{
ComboBox* const c = dynamic_cast<ComboBox*> (comp);
jassert (c != nullptr);
if (auto* const c = dynamic_cast<ComboBox*> (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<ComboBox*> (comp);
jassert (c != nullptr);
if (ComboBox* const c = dynamic_cast<ComboBox*> (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<ComboBox*> (component);
jassert (c != nullptr);
if (c == nullptr)
{
jassertfalse;
return;
}
String s;
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";
if (SettableTooltipClient* ttc = dynamic_cast<SettableTooltipClient*> (component))
if (auto* ttc = dynamic_cast<SettableTooltipClient*> (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";

View file

@ -544,15 +544,15 @@ private:
String getText() const override
{
Slider* s = dynamic_cast<Slider*> (component);
jassert (s != nullptr);
switch (rangeParam)
if (auto* s = dynamic_cast<Slider*> (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<Slider*> (component);
jassert (s != nullptr);
if (auto* s = dynamic_cast<Slider*> (component))
return String (s->getSkewFactor());
return String (s->getSkewFactor());
return {};
}
struct SliderSkewChangeAction : public ComponentUndoableAction<Slider>

View file

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

View file

@ -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(),

View file

@ -89,6 +89,12 @@ public:
//==============================================================================
void setFillType (Graphics& g, JucerDocument* const document, const Rectangle<int>& 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<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())
{
if (selectedElement != this)
if (selectedElement != nullptr && selectedElement != this)
{
if (auto* pe = dynamic_cast<PaintRoutineEditor*> (selectedElement->getParentComponent()))
{

View file

@ -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;

View file

@ -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;

View file

@ -33,18 +33,22 @@ template <class ElementType>
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)

View file

@ -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) + ")",

View file

@ -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<TreePanelBase*> (p);
if (! (p->isParentOf (e.eventComponent)))
{
auto* base = dynamic_cast<TreePanelBase*> (p);
if (base == nullptr)
base = dynamic_cast<ConcertinaTreeComponent*> (p)->getTree();
if (base == nullptr)
if (auto* concertina = dynamic_cast<ConcertinaTreeComponent*> (p))
base = concertina->getTree();
if (base != nullptr)
base->tree.clearSelectedItems();
if (base != nullptr)
base->tree.clearSelectedItems();
}
}
}
}

View file

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

View file

@ -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 <class F1, class E1, class FormatType>

View file

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

View file

@ -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:
//==============================================================================

View file

@ -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:

View file

@ -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;

View file

@ -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 <typename 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)
continue; // sysEx is tested separately

View file

@ -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;
}
}

View file

@ -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

View file

@ -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)
{

View file

@ -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",

View file

@ -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()

View file

@ -175,8 +175,12 @@ void AudioFormatReader::read (AudioBuffer<float>* 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);

View file

@ -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)

View file

@ -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<int*> chans (256);
std::vector<int> 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;

View file

@ -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)

View file

@ -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<Vst::ParamID> ((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)

View file

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

View file

@ -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",

View file

@ -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<Vst2::VstEvent*> (std::calloc (1, size)))
{
e->type = Vst2::kVstMidiType;
e->byteSize = sizeof (Vst2::VstMidiEvent);
return e;
}
return nullptr;
}
static void freeVSTEvent (Vst2::VstEvent* e)

View file

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

View file

@ -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()

View file

@ -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));
}

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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 */

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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)
{

View file

@ -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<IShellLink> shellLink;
ComSmartPtr<IPersistFile> persistFile;
CoInitialize (nullptr);
ignoreUnused (CoInitialize (nullptr));
return SUCCEEDED (shellLink.CoCreateInstance (CLSID_ShellLink))
&& SUCCEEDED (shellLink->SetPath (getFullPathName().toWideCharPointer()))

View file

@ -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()))

View file

@ -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<LPWSTR> (command.toWideCharPointer()),
nullptr, nullptr, TRUE, CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT,
nullptr, nullptr, &startupInfo, &processInfo) != FALSE;
JUCE_END_IGNORE_WARNINGS_MSVC
}
}

View file

@ -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
}

View file

@ -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<const uint8*> (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<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMarkLE1
&& c[1] == (uint8) byteOrderMarkLE2;
JUCE_END_IGNORE_WARNINGS_MSVC
}
private:

View file

@ -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<const uint8*> (possibleByteOrder);
return c[0] == (uint8) byteOrderMark1
&& c[1] == (uint8) byteOrderMark2
&& c[2] == (uint8) byteOrderMark3;
JUCE_END_IGNORE_WARNINGS_MSVC
}
private:

View file

@ -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);
}

View file

@ -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;

View file

@ -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
{

View file

@ -949,19 +949,16 @@ void ValueTree::moveChild (int currentIndex, int newIndex, UndoManager* undoMana
//==============================================================================
void ValueTree::createListOfChildren (OwnedArray<ValueTree>& 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<ValueTree>& newOrder, UndoManager* undoManager)
{
jassert (object != nullptr);
object->reorderChildren (newOrder, undoManager);
if (object != nullptr)
object->reorderChildren (newOrder, undoManager);
}
//==============================================================================

View file

@ -135,7 +135,9 @@ struct FFTFallback : public FFT::Instance
if (scratchSize < maxFFTScratchSpaceToAlloca)
{
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255)
performRealOnlyForwardTransform (static_cast<Complex<float>*> (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<Complex<float>*> (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<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 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;

View file

@ -148,7 +148,7 @@ struct FFTUnitTest : public UnitTest
HeapBlock<Complex<float>> 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)

View file

@ -128,6 +128,7 @@ public:
}
else
{
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6386)
auto* biases = static_cast<FloatType*> (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<int> (len));
JUCE_END_IGNORE_WARNINGS_MSVC
}
}

View file

@ -124,10 +124,12 @@ public:
}
else
{
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6255 6386)
auto* gains = static_cast<FloatType*> (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),

View file

@ -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[])

View file

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

View file

@ -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

View file

@ -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
//==============================================================================

View file

@ -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
{

View file

@ -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
{

View file

@ -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;
}
}

View file

@ -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 <typename PointOrRect>
@ -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;

View file

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

View file

@ -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,

View file

@ -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

View file

@ -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<TextButton*> (browseButton))

View file

@ -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<void, Deleter> ((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> (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<WCHAR*> (GlobalLock (medium.hGlobal));
text.copyToUTF16 (data, numBytes + 2);

View file

@ -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(); }
};

View file

@ -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<TopLevelWindow*> (kioskModeComp))
tlw->setUsingNativeTitleBar (! enableOrDisable);
if (enableOrDisable)
if (kioskModeComp != nullptr && enableOrDisable)
kioskModeComp->setBounds (getDisplays().getDisplayForRect (kioskModeComp->getScreenBounds())->totalArea);
}

View file

@ -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);

View file

@ -163,7 +163,7 @@ public:
{
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);
addAndMakeVisible (tc, 0);

View file

@ -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();

View file

@ -108,7 +108,7 @@ void TooltipWindow::displayTip (Point<int> 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

View file

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

View file

@ -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;
}

View file

@ -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;

View file

@ -77,10 +77,10 @@ bool OpenGLShaderProgram::addShader (const String& code, GLenum type)
if (status == (GLint) GL_FALSE)
{
GLchar infoLog [16384];
std::vector<GLchar> 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<GLchar> 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!

View file

@ -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;

View file

@ -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<IBaseFilter> nullFilter;
hr = nullFilter.CoCreateInstance (CLSID_NullRenderer);
@ -465,6 +468,13 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster
int index = 0;
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)))
{
ComSmartPtr<IEnumMoniker> 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<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))
{
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))
{
@ -719,7 +736,7 @@ private:
return false;
ComSmartPtr<IMoniker> moniker;
WCHAR buffer[128];
WCHAR buffer[128]{};
HRESULT hr = CreateItemMoniker (_T("!"), buffer, moniker.resetAndGetPointerAddress());
if (FAILED (hr))
return false;

View file

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