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

Use NullCheckedInvocation in more places

This commit is contained in:
Tom Poole 2023-09-26 11:06:31 +01:00
parent 84750f2f2a
commit ff0cb4ad5b
46 changed files with 145 additions and 258 deletions

View file

@ -379,7 +379,7 @@ public:
r.removeFromTop (20);
if (parametersComponent.get() != nullptr)
if (parametersComponent != nullptr)
parametersComponent->setBounds (r.removeFromTop (parametersComponent->getHeightNeeded()).reduced (20, 0));
}
@ -443,7 +443,7 @@ public:
transportSource.reset (new AudioTransportSource());
transportSource->addChangeListener (this);
if (readerSource.get() != nullptr)
if (readerSource != nullptr)
{
if (auto* device = audioDeviceManager.getCurrentAudioDevice())
{
@ -475,7 +475,7 @@ public:
void play()
{
if (readerSource.get() == nullptr)
if (readerSource == nullptr)
return;
if (transportSource->getCurrentPosition() >= transportSource->getLengthInSeconds()
@ -488,7 +488,7 @@ public:
void setLooping (bool shouldLoop)
{
if (readerSource.get() != nullptr)
if (readerSource != nullptr)
readerSource->setLooping (shouldLoop);
}
@ -633,7 +633,7 @@ private:
//==============================================================================
void valueChanged (Value& v) override
{
if (readerSource.get() != nullptr)
if (readerSource != nullptr)
readerSource->setLooping (v.getValue());
}

View file

@ -311,7 +311,7 @@ private:
{
SparseSet<int> selectedRows;
for (auto i = 0; i < midiDevices.size(); ++i)
if (midiDevices[i]->inDevice.get() != nullptr || midiDevices[i]->outDevice.get() != nullptr)
if (midiDevices[i]->inDevice != nullptr || midiDevices[i]->outDevice != nullptr)
selectedRows.addRange (Range<int> (i, i + 1));
lastSelectedItems = selectedRows;
@ -356,7 +356,7 @@ private:
void sendToOutputs (const MidiMessage& msg)
{
for (auto midiOutput : midiOutputs)
if (midiOutput->outDevice.get() != nullptr)
if (midiOutput->outDevice != nullptr)
midiOutput->outDevice->sendMessageNow (msg);
}

View file

@ -379,7 +379,7 @@ public:
r.removeFromTop (20);
if (parametersComponent.get() != nullptr)
if (parametersComponent != nullptr)
parametersComponent->setBounds (r.removeFromTop (parametersComponent->getHeightNeeded()).reduced (20, 0));
}
@ -443,7 +443,7 @@ public:
transportSource.reset (new AudioTransportSource());
transportSource->addChangeListener (this);
if (readerSource.get() != nullptr)
if (readerSource != nullptr)
{
if (auto* device = audioDeviceManager.getCurrentAudioDevice())
{
@ -475,7 +475,7 @@ public:
void play()
{
if (readerSource.get() == nullptr)
if (readerSource == nullptr)
return;
if (transportSource->getCurrentPosition() >= transportSource->getLengthInSeconds()
@ -488,7 +488,7 @@ public:
void setLooping (bool shouldLoop)
{
if (readerSource.get() != nullptr)
if (readerSource != nullptr)
readerSource->setLooping (shouldLoop);
}
@ -633,7 +633,7 @@ private:
//==============================================================================
void valueChanged (Value& v) override
{
if (readerSource.get() != nullptr)
if (readerSource != nullptr)
readerSource->setLooping (v.getValue());
}

View file

@ -123,7 +123,7 @@ public:
auto previewArea = shouldUseLandscapeLayout() ? r.removeFromLeft (r.getWidth() / 2)
: r.removeFromTop (r.getHeight() / 2);
if (cameraPreviewComp.get() != nullptr)
if (cameraPreviewComp != nullptr)
cameraPreviewComp->setBounds (previewArea);
if (shouldUseLandscapeLayout())

View file

@ -120,10 +120,10 @@ public:
shader->use();
if (uniforms->projectionMatrix.get() != nullptr)
if (uniforms->projectionMatrix != nullptr)
uniforms->projectionMatrix->setMatrix4 (getProjectionMatrix().mat, 1, false);
if (uniforms->viewMatrix.get() != nullptr)
if (uniforms->viewMatrix != nullptr)
uniforms->viewMatrix->setMatrix4 (getViewMatrix().mat, 1, false);
shape->draw (*attributes);
@ -276,10 +276,10 @@ private:
{
using namespace ::juce::gl;
if (position.get() != nullptr) glDisableVertexAttribArray (position->attributeID);
if (normal.get() != nullptr) glDisableVertexAttribArray (normal->attributeID);
if (sourceColour.get() != nullptr) glDisableVertexAttribArray (sourceColour->attributeID);
if (textureCoordIn.get() != nullptr) glDisableVertexAttribArray (textureCoordIn->attributeID);
if (position != nullptr) glDisableVertexAttribArray (position->attributeID);
if (normal != nullptr) glDisableVertexAttribArray (normal->attributeID);
if (sourceColour != nullptr) glDisableVertexAttribArray (sourceColour->attributeID);
if (textureCoordIn != nullptr) glDisableVertexAttribArray (textureCoordIn->attributeID);
}
std::unique_ptr<OpenGLShaderProgram::Attribute> position, normal, sourceColour, textureCoordIn;

View file

@ -110,10 +110,10 @@ struct OpenGLUtils
{
using namespace ::juce::gl;
if (position.get() != nullptr) glDisableVertexAttribArray (position->attributeID);
if (normal.get() != nullptr) glDisableVertexAttribArray (normal->attributeID);
if (sourceColour.get() != nullptr) glDisableVertexAttribArray (sourceColour->attributeID);
if (textureCoordIn.get() != nullptr) glDisableVertexAttribArray (textureCoordIn->attributeID);
if (position != nullptr) glDisableVertexAttribArray (position->attributeID);
if (normal != nullptr) glDisableVertexAttribArray (normal->attributeID);
if (sourceColour != nullptr) glDisableVertexAttribArray (sourceColour->attributeID);
if (textureCoordIn != nullptr) glDisableVertexAttribArray (textureCoordIn->attributeID);
}
std::unique_ptr<OpenGLShaderProgram::Attribute> position, normal, sourceColour, textureCoordIn;
@ -784,7 +784,7 @@ public:
// on demand, during the render callback.
freeAllContextObjects();
if (controlsOverlay.get() != nullptr)
if (controlsOverlay != nullptr)
controlsOverlay->updateShader();
}
@ -857,19 +857,19 @@ public:
shader->use();
if (uniforms->projectionMatrix.get() != nullptr)
if (uniforms->projectionMatrix != nullptr)
uniforms->projectionMatrix->setMatrix4 (getProjectionMatrix().mat, 1, false);
if (uniforms->viewMatrix.get() != nullptr)
if (uniforms->viewMatrix != nullptr)
uniforms->viewMatrix->setMatrix4 (getViewMatrix().mat, 1, false);
if (uniforms->texture.get() != nullptr)
if (uniforms->texture != nullptr)
uniforms->texture->set ((GLint) 0);
if (uniforms->lightPosition.get() != nullptr)
if (uniforms->lightPosition != nullptr)
uniforms->lightPosition->set (-15.0f, 10.0f, 15.0f, 0.0f);
if (uniforms->bouncingNumber.get() != nullptr)
if (uniforms->bouncingNumber != nullptr)
uniforms->bouncingNumber->set (bouncingNumber.getValue());
shape->draw (*attributes);

View file

@ -89,16 +89,14 @@ public:
messages.erase (messages.begin(), std::next (messages.begin(), numToRemove));
messages.insert (messages.end(), std::prev (end, numToAdd), end);
if (onChange != nullptr)
onChange();
NullCheckedInvocation::invoke (onChange);
}
void clear()
{
messages.clear();
if (onChange != nullptr)
onChange();
NullCheckedInvocation::invoke (onChange);
}
const MidiMessage& operator[] (size_t ind) const { return messages[ind]; }

View file

@ -234,7 +234,7 @@ public:
addAndMakeVisible (bypassButton);
// Clicking will bypass *everything*
bypassButton.onClick = [globalBypass] { if (globalBypass != nullptr) globalBypass (-1); };
bypassButton.onClick = [globalBypass] { NullCheckedInvocation::invoke (globalBypass, -1); };
setSize (300, 80);
}

View file

@ -199,7 +199,7 @@ public:
shouldExit = true;
if (webStream.get() != nullptr)
if (webStream != nullptr)
webStream->cancel();
}

View file

@ -155,7 +155,7 @@ public:
// invoked by the 'ping' button.
void pingChildProcess()
{
if (coordinatorProcess.get() != nullptr)
if (coordinatorProcess != nullptr)
coordinatorProcess->sendPingMessageToWorker();
else
logMessage ("Child process is not running!");

View file

@ -129,7 +129,7 @@ public:
}
}
if (oldOpenness.get() != nullptr)
if (oldOpenness != nullptr)
treeView.restoreOpennessState (*oldOpenness, false);
}
}

View file

@ -312,12 +312,12 @@ private:
{
std::unique_ptr<XmlElement> openness;
if (rootItem.get() != nullptr)
if (rootItem != nullptr)
openness = rootItem->getOpennessState();
createNewRootNode();
if (openness.get() != nullptr && rootItem.get() != nullptr)
if (openness != nullptr && rootItem != nullptr)
rootItem->restoreOpennessState (*openness);
}
@ -336,7 +336,7 @@ private:
}
// if we have a valid TreeViewItem hide any old error messages and set our TreeView to use it
if (rootItem.get() != nullptr)
if (rootItem != nullptr)
errorMessage.clear();
errorMessage.setVisible (! errorMessage.isEmpty());