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

More zero -> nullptr fixes

This commit is contained in:
jules 2018-10-09 11:42:55 +01:00
parent 132017558f
commit 359132ed55
15 changed files with 28 additions and 21 deletions

View file

@ -24,7 +24,7 @@ class Chain : public Test
public: public:
Chain() Chain()
{ {
b2Body* ground = NULL; b2Body* ground = {};
{ {
b2BodyDef bd; b2BodyDef bd;
ground = m_world->CreateBody(&bd); ground = m_world->CreateBody(&bd);

View file

@ -153,7 +153,7 @@ public:
auto inputSamp = 0.0f; auto inputSamp = 0.0f;
for (auto j = numInputChannels; --j >= 0;) for (auto j = numInputChannels; --j >= 0;)
if (inputChannelData[j] != 0) if (inputChannelData[j] != nullptr)
inputSamp += inputChannelData[j][i]; inputSamp += inputChannelData[j][i];
recordingBuffer[recordedSampleNum] = inputSamp; recordingBuffer[recordedSampleNum] = inputSamp;
@ -164,7 +164,7 @@ public:
auto outputSamp = (playingSampleNum < testSound.getNumSamples()) ? playBuffer[playingSampleNum] : 0.0f; auto outputSamp = (playingSampleNum < testSound.getNumSamples()) ? playBuffer[playingSampleNum] : 0.0f;
for (auto j = numOutputChannels; --j >= 0;) for (auto j = numOutputChannels; --j >= 0;)
if (outputChannelData[j] != 0) if (outputChannelData[j] != nullptr)
outputChannelData[j][i] = outputSamp; outputChannelData[j][i] = outputSamp;
++playingSampleNum; ++playingSampleNum;
@ -174,7 +174,7 @@ public:
{ {
// We need to clear the output buffers, in case they're full of junk.. // We need to clear the output buffers, in case they're full of junk..
for (int i = 0; i < numOutputChannels; ++i) for (int i = 0; i < numOutputChannels; ++i)
if (outputChannelData[i] != 0) if (outputChannelData[i] != nullptr)
zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples); zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples);
} }
} }

View file

@ -235,7 +235,8 @@ private:
{ {
AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, "This is an ok/cancel AlertWindow", AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, "This is an ok/cancel AlertWindow",
"And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.", "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
{}, {}, 0, ModalCallbackFunction::forComponent (alertBoxResultChosen, this)); {}, {}, {},
ModalCallbackFunction::forComponent (alertBoxResultChosen, this));
} }
else if (type == calloutBoxWindow) else if (type == calloutBoxWindow)
{ {

View file

@ -236,7 +236,7 @@ private:
{ {
if (position.get() != nullptr) if (position.get() != nullptr)
{ {
glContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), 0); glContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), nullptr);
glContext.extensions.glEnableVertexAttribArray (position->attributeID); glContext.extensions.glEnableVertexAttribArray (position->attributeID);
} }
@ -325,7 +325,7 @@ private:
vertexBuffer->bind(); vertexBuffer->bind();
glAttributes.enable (glContext); glAttributes.enable (glContext);
glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, 0); glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, nullptr);
glAttributes.disable (glContext); glAttributes.disable (glContext);
} }
} }

View file

@ -81,7 +81,7 @@ struct OpenGLDemoClasses
{ {
if (position.get() != nullptr) if (position.get() != nullptr)
{ {
openGLContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), 0); openGLContext.extensions.glVertexAttribPointer (position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof (Vertex), nullptr);
openGLContext.extensions.glEnableVertexAttribArray (position->attributeID); openGLContext.extensions.glEnableVertexAttribArray (position->attributeID);
} }
@ -173,7 +173,7 @@ struct OpenGLDemoClasses
vertexBuffer->bind(); vertexBuffer->bind();
attributes.enable (openGLContext); attributes.enable (openGLContext);
glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, 0); glDrawElements (GL_TRIANGLES, vertexBuffer->numIndices, GL_UNSIGNED_INT, nullptr);
attributes.disable (openGLContext); attributes.disable (openGLContext);
} }
} }

View file

@ -292,7 +292,7 @@ struct ButtonsPage : public Component
over.setStrokeThickness (4.0f); over.setStrokeThickness (4.0f);
auto* db = addToList (new DrawableButton (String (i + 5) + " points", DrawableButton::ImageAboveTextLabel)); auto* db = addToList (new DrawableButton (String (i + 5) + " points", DrawableButton::ImageAboveTextLabel));
db->setImages (&normal, &over, 0); db->setImages (&normal, &over, nullptr);
db->setClickingTogglesState (true); db->setClickingTogglesState (true);
db->setRadioGroupId (23456); db->setRadioGroupId (23456);
@ -391,7 +391,7 @@ struct ButtonsPage : public Component
{ {
// create an image-on-button-shape button from the same drawables.. // create an image-on-button-shape button from the same drawables..
auto db = addToList (new DrawableButton ("Button 3", DrawableButton::ImageOnButtonBackground)); auto db = addToList (new DrawableButton ("Button 3", DrawableButton::ImageOnButtonBackground));
db->setImages (&normal, 0, 0); db->setImages (&normal, nullptr, nullptr);
db->setBounds (260, 160, 110, 25); db->setBounds (260, 160, 110, 25);
db->setTooltip ("This is a DrawableButton on a standard button background"); db->setTooltip ("This is a DrawableButton on a standard button background");
db->onClick = popupMessageCallback; db->onClick = popupMessageCallback;
@ -636,7 +636,7 @@ private:
{ {
auto* drawable = new DrawableImage(); auto* drawable = new DrawableImage();
drawable->setImage (getImageFromAssets ("juce_icon.png")); drawable->setImage (getImageFromAssets ("juce_icon.png"));
return new ToolbarButton (itemId, "juce!", drawable, 0); return new ToolbarButton (itemId, "juce!", drawable, nullptr);
} }
case customComboBox: return new CustomToolbarComboBox (itemId); case customComboBox: return new CustomToolbarComboBox (itemId);
default: break; default: break;
@ -671,7 +671,7 @@ private:
} }
auto* image = iconsFromZipFile[iconNames.indexOf (filename)]->createCopy(); auto* image = iconsFromZipFile[iconNames.indexOf (filename)]->createCopy();
return new ToolbarButton (itemId, text, image, 0); return new ToolbarButton (itemId, text, image, nullptr);
} }
// Demonstrates how to put a custom component into a toolbar - this one contains // Demonstrates how to put a custom component into a toolbar - this one contains

View file

@ -180,7 +180,7 @@ public:
void mouseDrag (const MouseEvent& e) override void mouseDrag (const MouseEvent& e) override
{ {
// as there's no titlebar we have to manage the dragging ourselves // as there's no titlebar we have to manage the dragging ourselves
dragger.dragComponent (this, e, 0); dragger.dragComponent (this, e, nullptr);
} }
void paint (Graphics& g) override void paint (Graphics& g) override

View file

@ -122,7 +122,7 @@ private:
parentWidth = 50.0f, parentHeight = 50.0f; parentWidth = 50.0f, parentHeight = 50.0f;
Colour colour; Colour colour;
Thread::ThreadID threadId = 0; Thread::ThreadID threadId = {};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BouncingBallComp) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BouncingBallComp)
}; };

View file

@ -382,7 +382,7 @@ struct Program
//============================================================================== //==============================================================================
static constexpr uint32 programHeaderSize = 10; static constexpr uint32 programHeaderSize = 10;
const uint8* programStart = 0; const uint8* programStart = nullptr;
const uint32 maxProgramSize; const uint32 maxProgramSize;
private: private:

View file

@ -37,6 +37,9 @@
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wsign-conversion" #pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wfloat-conversion" #pragma clang diagnostic ignored "-Wfloat-conversion"
#if __has_warning("-Wzero-as-null-pointer-constant")
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#elif defined (__GNUC__) #elif defined (__GNUC__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" #pragma GCC diagnostic ignored "-Wunused-but-set-variable"

View file

@ -57,6 +57,9 @@
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wconversion"
#if __has_warning("-Wzero-as-null-pointer-constant")
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#endif
#endif #endif
#include <climits> #include <climits>

View file

@ -247,7 +247,7 @@ public:
//============================================================================== //==============================================================================
bool OpenGLHelpers::isContextActive() bool OpenGLHelpers::isContextActive()
{ {
return CGLGetCurrentContext() != 0; return CGLGetCurrentContext() != CGLContextObj();
} }
} // namespace juce } // namespace juce

View file

@ -1196,7 +1196,7 @@ void OpenGLContext::copyTexture (const Rectangle<int>& targetClipArea,
extensions.glBufferData (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW); extensions.glBufferData (GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW);
auto index = (GLuint) program.params.positionAttribute.attributeID; auto index = (GLuint) program.params.positionAttribute.attributeID;
extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, 0); extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, nullptr);
extensions.glEnableVertexAttribArray (index); extensions.glEnableVertexAttribArray (index);
JUCE_CHECK_OPENGL_ERROR JUCE_CHECK_OPENGL_ERROR

View file

@ -58,7 +58,7 @@ public:
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
JUCE_CHECK_OPENGL_ERROR JUCE_CHECK_OPENGL_ERROR
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
JUCE_CHECK_OPENGL_ERROR JUCE_CHECK_OPENGL_ERROR
context.extensions.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0); context.extensions.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);

View file

@ -422,7 +422,7 @@ struct ShaderPrograms : public ReferenceCountedObject
void bindAttributes (OpenGLContext& context) void bindAttributes (OpenGLContext& context)
{ {
context.extensions.glVertexAttribPointer ((GLuint) positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, (void*) 0); context.extensions.glVertexAttribPointer ((GLuint) positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, nullptr);
context.extensions.glVertexAttribPointer ((GLuint) colourAttribute.attributeID, 4, GL_UNSIGNED_BYTE, GL_TRUE, 8, (void*) 4); context.extensions.glVertexAttribPointer ((GLuint) colourAttribute.attributeID, 4, GL_UNSIGNED_BYTE, GL_TRUE, 8, (void*) 4);
context.extensions.glEnableVertexAttribArray ((GLuint) positionAttribute.attributeID); context.extensions.glEnableVertexAttribArray ((GLuint) positionAttribute.attributeID);
context.extensions.glEnableVertexAttribArray ((GLuint) colourAttribute.attributeID); context.extensions.glEnableVertexAttribArray ((GLuint) colourAttribute.attributeID);
@ -1279,7 +1279,7 @@ struct StateHelpers
context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, (GLsizeiptr) ((size_t) numVertices * sizeof (VertexInfo)), vertexData); context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, (GLsizeiptr) ((size_t) numVertices * sizeof (VertexInfo)), vertexData);
// NB: If you get a random crash in here and are running in a Parallels VM, it seems to be a bug in // NB: If you get a random crash in here and are running in a Parallels VM, it seems to be a bug in
// their driver.. Can't find a workaround unfortunately. // their driver.. Can't find a workaround unfortunately.
glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0); glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, nullptr);
JUCE_CHECK_OPENGL_ERROR JUCE_CHECK_OPENGL_ERROR
numVertices = 0; numVertices = 0;
} }