Browse Source

More zero -> nullptr fixes

tags/2021-05-28
jules 7 years ago
parent
commit
359132ed55
15 changed files with 28 additions and 21 deletions
  1. +1
    -1
      examples/Assets/Box2DTests/Chain.h
  2. +3
    -3
      examples/Audio/AudioLatencyDemo.h
  3. +2
    -1
      examples/GUI/DialogsDemo.h
  4. +2
    -2
      examples/GUI/OpenGLAppDemo.h
  5. +2
    -2
      examples/GUI/OpenGLDemo.h
  6. +4
    -4
      examples/GUI/WidgetsDemo.h
  7. +1
    -1
      examples/GUI/WindowsDemo.h
  8. +1
    -1
      examples/Utilities/MultithreadingDemo.h
  9. +1
    -1
      modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h
  10. +3
    -0
      modules/juce_box2d/juce_box2d.cpp
  11. +3
    -0
      modules/juce_box2d/juce_box2d.h
  12. +1
    -1
      modules/juce_opengl/native/juce_OpenGL_osx.h
  13. +1
    -1
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp
  14. +1
    -1
      modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp
  15. +2
    -2
      modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp

+ 1
- 1
examples/Assets/Box2DTests/Chain.h 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);


+ 3
- 3
examples/Audio/AudioLatencyDemo.h 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);
} }
} }


+ 2
- 1
examples/GUI/DialogsDemo.h 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)
{ {


+ 2
- 2
examples/GUI/OpenGLAppDemo.h 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);
} }
} }


+ 2
- 2
examples/GUI/OpenGLDemo.h 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);
} }
} }


+ 4
- 4
examples/GUI/WidgetsDemo.h 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


+ 1
- 1
examples/GUI/WindowsDemo.h 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


+ 1
- 1
examples/Utilities/MultithreadingDemo.h 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)
}; };


+ 1
- 1
modules/juce_blocks_basics/littlefoot/juce_LittleFootRunner.h 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:


+ 3
- 0
modules/juce_box2d/juce_box2d.cpp 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"


+ 3
- 0
modules/juce_box2d/juce_box2d.h 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>


+ 1
- 1
modules/juce_opengl/native/juce_OpenGL_osx.h View File

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

+ 1
- 1
modules/juce_opengl/opengl/juce_OpenGLContext.cpp 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


+ 1
- 1
modules/juce_opengl/opengl/juce_OpenGLFrameBuffer.cpp 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);


+ 2
- 2
modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp 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;
} }


Loading…
Cancel
Save