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

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

@ -235,8 +235,7 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
{
if (currentProject == nullptr)
{
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
@ -259,8 +258,7 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
if (! closedSuccessfully)
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -269,8 +267,7 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
{
parent->setProject (nullptr);
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
};
if (askUserToSave == OpenDocumentManager::SaveIfNeeded::no)
@ -286,8 +283,8 @@ void MainWindow::closeCurrentProject (OpenDocumentManager::SaveIfNeeded askUserT
if (saveResult == FileBasedDocument::savedOk)
setProjectAndCallback();
else if (callback != nullptr)
callback (false);
else
NullCheckedInvocation::invoke (callback, false);
});
});
}
@ -392,15 +389,13 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
parent->currentProject->updateDeprecatedProjectSettingsInteractively();
}
if (callback != nullptr)
callback (saveResult);
NullCheckedInvocation::invoke (callback, saveResult);
});
return;
}
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -413,9 +408,7 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
if (parent != nullptr)
{
parent->createProjectContentCompIfNeeded();
if (callback != nullptr)
callback (parent->getProjectContentComponent()->showEditorForFile (file, true));
NullCheckedInvocation::invoke (callback, parent->getProjectContentComponent()->showEditorForFile (file, true));
}
};
@ -428,9 +421,7 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
if (openedSuccessfully)
{
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
@ -444,8 +435,7 @@ void MainWindow::openFile (const File& file, std::function<void (bool)> callback
return;
}
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
}
void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callback)
@ -454,9 +444,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
if (! generator->hasValidPIP())
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -469,9 +457,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
generatorResult.getErrorMessage());
messageBox = AlertWindow::showScopedAsync (options, nullptr);
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -482,9 +468,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
"Failed to create Main.cpp.");
messageBox = AlertWindow::showScopedAsync (options, nullptr);
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -500,16 +484,13 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
"Failed to open .jucer file.");
parent->messageBox = AlertWindow::showScopedAsync (options, nullptr);
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
parent->setupTemporaryPIPProject (*generator);
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
});
}
@ -746,9 +727,7 @@ static void askAllWindowsToCloseRecursive (WeakReference<MainWindowList> parent,
{
if (parent->windows.size() == 0)
{
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
@ -759,9 +738,7 @@ static void askAllWindowsToCloseRecursive (WeakReference<MainWindowList> parent,
if (! closedSuccessfully)
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -845,9 +822,7 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
{
if (! file.exists())
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -857,9 +832,7 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
{
w->toFront (true);
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
}
@ -893,8 +866,7 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
parent->closeWindow (w);
}
if (callback != nullptr)
callback (openedSuccessfully);
NullCheckedInvocation::invoke (callback, openedSuccessfully);
});
return;
@ -902,8 +874,8 @@ void MainWindowList::openFile (const File& file, std::function<void (bool)> call
getFrontmostWindow()->openFile (file, [parent, callback] (bool openedSuccessfully)
{
if (parent != nullptr && callback != nullptr)
callback (openedSuccessfully);
if (parent != nullptr)
NullCheckedInvocation::invoke (callback, openedSuccessfully);
});
}

View file

@ -172,9 +172,7 @@ void OpenDocumentManager::saveIfNeededAndUserAgrees (OpenDocumentManager::Docume
{
if (! doc->needsSaving())
{
if (callback != nullptr)
callback (FileBasedDocument::savedOk);
NullCheckedInvocation::invoke (callback, FileBasedDocument::savedOk);
return;
}
@ -197,14 +195,12 @@ void OpenDocumentManager::saveIfNeededAndUserAgrees (OpenDocumentManager::Docume
if (parent == nullptr)
return;
if (callback != nullptr)
callback (hasSaved ? FileBasedDocument::savedOk : FileBasedDocument::failedToWriteToFile);
NullCheckedInvocation::invoke (callback, hasSaved ? FileBasedDocument::savedOk : FileBasedDocument::failedToWriteToFile);
});
return;
}
if (callback != nullptr)
callback (r == 2 ? FileBasedDocument::savedOk : FileBasedDocument::userCancelledSave);
NullCheckedInvocation::invoke (callback, r == 2 ? FileBasedDocument::savedOk : FileBasedDocument::userCancelledSave);
});
}
@ -233,9 +229,7 @@ void OpenDocumentManager::closeDocumentAsync (Document* doc, SaveIfNeeded saveIf
{
if (! documents.contains (doc))
{
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
@ -249,16 +243,13 @@ void OpenDocumentManager::closeDocumentAsync (Document* doc, SaveIfNeeded saveIf
if (result != FileBasedDocument::savedOk)
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
auto closed = parent->closeDocumentWithoutSaving (doc);
if (callback != nullptr)
callback (closed);
NullCheckedInvocation::invoke (callback, closed);
});
return;
@ -266,8 +257,7 @@ void OpenDocumentManager::closeDocumentAsync (Document* doc, SaveIfNeeded saveIf
auto closed = closeDocumentWithoutSaving (doc);
if (callback != nullptr)
callback (closed);
NullCheckedInvocation::invoke (callback, closed);
}
void OpenDocumentManager::closeFileWithoutSaving (const File& f)
@ -286,9 +276,7 @@ static void closeLastAsyncRecusrsive (WeakReference<OpenDocumentManager> parent,
if (lastIndex < 0)
{
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
@ -301,9 +289,7 @@ static void closeLastAsyncRecusrsive (WeakReference<OpenDocumentManager> parent,
if (! closedSuccessfully)
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -334,9 +320,7 @@ void OpenDocumentManager::closeLastDocumentUsingProjectRecursive (WeakReference<
if (! closedSuccessfully)
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -348,8 +332,7 @@ void OpenDocumentManager::closeLastDocumentUsingProjectRecursive (WeakReference<
}
}
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
}
void OpenDocumentManager::closeAllDocumentsUsingProjectAsync (Project& project, SaveIfNeeded askUserToSave, std::function<void (bool)> callback)

View file

@ -137,9 +137,7 @@ void BinaryResources::browseForResource (const String& title,
{
if (safeThis == nullptr)
{
if (callback != nullptr)
callback ({});
NullCheckedInvocation::invoke (callback, String{});
return;
}
@ -169,8 +167,7 @@ void BinaryResources::browseForResource (const String& title,
}
}
if (callback != nullptr)
callback (resourceName);
NullCheckedInvocation::invoke (callback, resourceName);
});
}

View file

@ -517,8 +517,7 @@ private:
if (oldCallback != nullptr)
start (oldCallback);
if (notifyChannelsChanged != nullptr)
notifyChannelsChanged();
NullCheckedInvocation::invoke (notifyChannelsChanged);
}
}

View file

@ -120,7 +120,7 @@ public:
//==============================================================================
void systemRequestedQuit() override
{
if (mainWindow.get() != nullptr)
if (mainWindow != nullptr)
mainWindow->pluginHolder->savePluginState();
if (ModalComponentManager::getInstance()->cancelAllModalComponents())

View file

@ -466,8 +466,7 @@ public:
}
// Send VST events to the host.
if (hostCallback != nullptr)
hostCallback (&vstEffect, Vst2::audioMasterProcessEvents, 0, 0, outgoingEvents.events, 0);
NullCheckedInvocation::invoke (hostCallback, &vstEffect, Vst2::audioMasterProcessEvents, 0, 0, outgoingEvents.events, 0.0f);
#elif JUCE_DEBUG
/* This assertion is caused when you've added some events to the
midiMessages array in your processBlock() method, which usually means
@ -545,10 +544,7 @@ public:
some hosts rely on this behaviour.
*/
if (vstEffect.flags & Vst2::effFlagsIsSynth || JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect)
{
if (hostCallback != nullptr)
hostCallback (&vstEffect, Vst2::audioMasterWantMidi, 0, 1, nullptr, 0);
}
NullCheckedInvocation::invoke (hostCallback, &vstEffect, Vst2::audioMasterWantMidi, 0, 1, nullptr, 0.0f);
if (detail::PluginUtilities::getHostType().isAbletonLive()
&& hostCallback != nullptr
@ -697,20 +693,17 @@ public:
return;
}
if (hostCallback != nullptr)
hostCallback (&vstEffect, Vst2::audioMasterAutomate, index, 0, nullptr, newValue);
NullCheckedInvocation::invoke (hostCallback, &vstEffect, Vst2::audioMasterAutomate, index, 0, nullptr, newValue);
}
void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index) override
{
if (hostCallback != nullptr)
hostCallback (&vstEffect, Vst2::audioMasterBeginEdit, index, 0, nullptr, 0);
NullCheckedInvocation::invoke (hostCallback, &vstEffect, Vst2::audioMasterBeginEdit, index, 0, nullptr, 0.0f);
}
void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index) override
{
if (hostCallback != nullptr)
hostCallback (&vstEffect, Vst2::audioMasterEndEdit, index, 0, nullptr, 0);
NullCheckedInvocation::invoke (hostCallback, &vstEffect, Vst2::audioMasterEndEdit, index, 0, nullptr, 0.0f);
}
void parameterValueChanged (int, float newValue) override

View file

@ -157,8 +157,8 @@ public:
jassert (insideLADSPACallback == 0);
if (handle != nullptr && plugin != nullptr && plugin->cleanup != nullptr)
plugin->cleanup (handle);
if (handle != nullptr && plugin != nullptr)
NullCheckedInvocation::invoke (plugin->cleanup, handle);
initialised = false;
module = nullptr;
@ -209,8 +209,8 @@ public:
setLatencySamples (0);
// Some plugins crash if this doesn't happen:
if (plugin->activate != nullptr) plugin->activate (handle);
if (plugin->deactivate != nullptr) plugin->deactivate (handle);
NullCheckedInvocation::invoke (plugin->activate, handle);
NullCheckedInvocation::invoke (plugin->deactivate, handle);
}
//==============================================================================
@ -275,15 +275,14 @@ public:
firstParam->setValue (old);
}
if (plugin->activate != nullptr)
plugin->activate (handle);
NullCheckedInvocation::invoke (plugin->activate, handle);
}
}
void releaseResources() override
{
if (handle != nullptr && plugin->deactivate != nullptr)
plugin->deactivate (handle);
NullCheckedInvocation::invoke (plugin->deactivate, handle);
tempBuffer.setSize (1, 1);
}

View file

@ -100,8 +100,8 @@ public:
{
const auto toReturn = result.extract (obj);
if (result.isOk() && addRefFn != nullptr && *obj != nullptr)
addRefFn (*obj);
if (result.isOk() && *obj != nullptr)
NullCheckedInvocation::invoke (addRefFn, *obj);
return toReturn;
}

View file

@ -105,8 +105,7 @@ void ParameterAttachment::parameterValueChanged (int, float newValue)
void ParameterAttachment::handleAsyncUpdate()
{
if (setValue != nullptr)
setValue (parameter.convertFrom0to1 (lastValue));
NullCheckedInvocation::invoke (setValue, parameter.convertFrom0to1 (lastValue));
}
//==============================================================================

View file

@ -293,8 +293,7 @@ private:
void valueChanged (Value&) override
{
if (onDefaultChange != nullptr)
onDefaultChange();
NullCheckedInvocation::invoke (onDefaultChange);
}
void referToWithDefault (ValueTree v,

View file

@ -134,8 +134,7 @@ std::vector<NetworkServiceDiscovery::Service> NetworkServiceDiscovery::Available
void NetworkServiceDiscovery::AvailableServiceList::handleAsyncUpdate()
{
if (onChange != nullptr)
onChange();
NullCheckedInvocation::invoke (onChange);
}
void NetworkServiceDiscovery::AvailableServiceList::handleMessage (const XmlElement& xml)

View file

@ -110,14 +110,12 @@ struct AppDelegateClass : public ObjCClass<NSObject>
addMethod (@selector (mainMenuTrackingBegan:), [] (id /*self*/, SEL, NSNotification*)
{
if (menuTrackingChangedCallback != nullptr)
menuTrackingChangedCallback (true);
NullCheckedInvocation::invoke (menuTrackingChangedCallback, true);
});
addMethod (@selector (mainMenuTrackingEnded:), [] (id /*self*/, SEL, NSNotification*)
{
if (menuTrackingChangedCallback != nullptr)
menuTrackingChangedCallback (false);
NullCheckedInvocation::invoke (menuTrackingChangedCallback, false);
});
// (used as a way of running a dummy thread)

View file

@ -164,8 +164,7 @@ private:
}
if (message == WM_SETTINGCHANGE)
if (settingChangeCallback != nullptr)
settingChangeCallback();
NullCheckedInvocation::invoke (settingChangeCallback);
}
return DefWindowProc (h, message, wParam, lParam);

View file

@ -178,8 +178,7 @@ void Typeface::clearTypefaceCache()
RenderingHelpers::SoftwareRendererSavedState::clearGlyphCache();
if (clearOpenGLGlyphCache != nullptr)
clearOpenGLGlyphCache();
NullCheckedInvocation::invoke (clearOpenGLGlyphCache);
}
//==============================================================================

View file

@ -421,8 +421,7 @@ void Button::sendClickMessage (const ModifierKeys& modifiers)
if (checker.shouldBailOut())
return;
if (onClick != nullptr)
onClick();
NullCheckedInvocation::invoke (onClick);
}
void Button::sendStateMessage()
@ -439,8 +438,7 @@ void Button::sendStateMessage()
if (checker.shouldBailOut())
return;
if (onStateChange != nullptr)
onStateChange();
NullCheckedInvocation::invoke (onStateChange);
}
//==============================================================================

View file

@ -128,9 +128,7 @@ void MultiDocumentPanel::closeLastDocumentRecursive (SafePointer<MultiDocumentPa
{
if (parent->components.isEmpty())
{
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
@ -143,9 +141,7 @@ void MultiDocumentPanel::closeLastDocumentRecursive (SafePointer<MultiDocumentPa
if (! closeResult)
{
if (callback != nullptr)
callback (false);
NullCheckedInvocation::invoke (callback, false);
return;
}
@ -436,9 +432,7 @@ void MultiDocumentPanel::closeDocumentAsync (Component* component,
if (component == nullptr)
{
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
return;
}
@ -455,8 +449,7 @@ void MultiDocumentPanel::closeDocumentAsync (Component* component,
if (closedSuccessfully)
parent->closeDocumentInternal (component);
if (callback != nullptr)
callback (closedSuccessfully);
NullCheckedInvocation::invoke (callback, closedSuccessfully);
});
return;
@ -469,8 +462,7 @@ void MultiDocumentPanel::closeDocumentAsync (Component* component,
jassertfalse;
}
if (callback != nullptr)
callback (true);
NullCheckedInvocation::invoke (callback, true);
JUCE_END_IGNORE_WARNINGS_MSVC
}

View file

@ -113,8 +113,7 @@ void SidePanel::showOrHide (bool show)
void SidePanel::moved()
{
if (onPanelMove != nullptr)
onPanelMove();
NullCheckedInvocation::invoke (onPanelMove);
}
void SidePanel::resized()
@ -253,8 +252,7 @@ void SidePanel::changeListenerCallback (ChangeBroadcaster*)
{
if (! Desktop::getInstance().getAnimator().isAnimating (this))
{
if (onPanelShowHide != nullptr)
onPanelShowHide (isShowing);
NullCheckedInvocation::invoke (onPanelShowHide, isShowing);
if (isVisible() && ! isShowing)
setVisible (false);

View file

@ -340,8 +340,7 @@ public:
X11Symbols::getInstance()->xUngrabPointer (getDisplay(), CurrentTime);
}
if (completionCallback != nullptr)
completionCallback();
NullCheckedInvocation::invoke (completionCallback);
dragging = false;
}

View file

@ -410,8 +410,7 @@ struct DisplaySettingsChangeCallback : private DeletedAtShutdown
static void displayReconfigurationCallback (CGDirectDisplayID, CGDisplayChangeSummaryFlags, void* userInfo)
{
if (auto* thisPtr = static_cast<DisplaySettingsChangeCallback*> (userInfo))
if (thisPtr->forceDisplayUpdate != nullptr)
thisPtr->forceDisplayUpdate();
NullCheckedInvocation::invoke (thisPtr->forceDisplayUpdate);
}
std::function<void()> forceDisplayUpdate;

View file

@ -423,8 +423,7 @@ static void setDPIAwareness()
&& SUCCEEDED (setProcessDPIAwareness (DPI_Awareness::DPI_Awareness_System_Aware)))
return;
if (setProcessDPIAware != nullptr)
setProcessDPIAware();
NullCheckedInvocation::invoke (setProcessDPIAware);
}
static bool isPerMonitorDPIAwareProcess()
@ -3065,8 +3064,8 @@ private:
// This avoids a rare stuck-button problem when focus is lost unexpectedly, but must
// not be called as part of a move, in case it's actually a mouse-drag from another
// app which ends up here when we get focus before the mouse is released..
if (isMouseDownEvent && getNativeRealtimeModifiers != nullptr)
getNativeRealtimeModifiers();
if (isMouseDownEvent)
NullCheckedInvocation::invoke (getNativeRealtimeModifiers);
updateKeyModifiers();
@ -3955,8 +3954,8 @@ public:
{
// Ensure that non-client areas are scaled for per-monitor DPI awareness v1 - can't
// do this in peerWindowProc as we have no window at this point
if (message == WM_NCCREATE && enableNonClientDPIScaling != nullptr)
enableNonClientDPIScaling (h);
if (message == WM_NCCREATE)
NullCheckedInvocation::invoke (enableNonClientDPIScaling, h);
if (auto* peer = getOwnerOfWindow (h))
{

View file

@ -2261,8 +2261,7 @@ void XWindowSystem::setScreenSaverEnabled (bool enabled) const
XWindowSystemUtilities::ScopedXLock xLock;
if (xScreenSaverSuspend != nullptr)
xScreenSaverSuspend (display, ! enabled);
NullCheckedInvocation::invoke (xScreenSaverSuspend, display, ! enabled);
}
Point<float> XWindowSystem::getCurrentMousePosition() const

View file

@ -334,8 +334,7 @@ void MultiChoicePropertyComponent::setExpanded (bool shouldBeExpanded) noexcept
if (auto* propertyPanel = findParentComponentOfClass<PropertyPanel>())
propertyPanel->resized();
if (onHeightChange != nullptr)
onHeightChange();
NullCheckedInvocation::invoke (onHeightChange);
expandButton.setTransform (AffineTransform::rotation (expanded ? MathConstants<float>::pi : MathConstants<float>::twoPi,
(float) expandButton.getBounds().getCentreX(),

View file

@ -625,8 +625,7 @@ void ComboBox::handleAsyncUpdate()
if (checker.shouldBailOut())
return;
if (onChange != nullptr)
onChange();
NullCheckedInvocation::invoke (onChange);
if (checker.shouldBailOut())
return;

View file

@ -202,8 +202,7 @@ void Label::editorShown (TextEditor* textEditor)
if (checker.shouldBailOut())
return;
if (onEditorShow != nullptr)
onEditorShow();
NullCheckedInvocation::invoke (onEditorShow);
}
void Label::editorAboutToBeHidden (TextEditor* textEditor)
@ -214,8 +213,7 @@ void Label::editorAboutToBeHidden (TextEditor* textEditor)
if (checker.shouldBailOut())
return;
if (onEditorHide != nullptr)
onEditorHide();
NullCheckedInvocation::invoke (onEditorHide);
}
void Label::showEditor()
@ -463,8 +461,7 @@ void Label::callChangeListeners()
if (checker.shouldBailOut())
return;
if (onTextChange != nullptr)
onTextChange();
NullCheckedInvocation::invoke (onTextChange);
}
//==============================================================================

View file

@ -359,8 +359,7 @@ public:
if (checker.shouldBailOut())
return;
if (owner.onValueChange != nullptr)
owner.onValueChange();
NullCheckedInvocation::invoke (owner.onValueChange);
if (checker.shouldBailOut())
return;
@ -379,8 +378,7 @@ public:
if (checker.shouldBailOut())
return;
if (owner.onDragStart != nullptr)
owner.onDragStart();
NullCheckedInvocation::invoke (owner.onDragStart);
}
void sendDragEnd()
@ -394,8 +392,7 @@ public:
if (checker.shouldBailOut())
return;
if (owner.onDragEnd != nullptr)
owner.onDragEnd();
NullCheckedInvocation::invoke (owner.onDragEnd);
}
void incrementOrDecrement (double delta)

View file

@ -440,8 +440,7 @@ struct OSCReceiver::Pimpl : private Thread,
}
catch (const OSCFormatError&)
{
if (formatErrorHandler != nullptr)
formatErrorHandler (data, (int) dataSize);
NullCheckedInvocation::invoke (formatErrorHandler, data, (int) dataSize);
}
}

View file

@ -2932,16 +2932,14 @@ private:
void cameraDeviceError (const String& error)
{
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (error);
NullCheckedInvocation::invoke (owner.onErrorOccurred, error);
}
void invokeCameraOpenCallback (const String& error)
{
JUCE_CAMERA_LOG ("invokeCameraOpenCallback(), error = " + error);
if (cameraOpenCallback != nullptr)
cameraOpenCallback (cameraId, error);
NullCheckedInvocation::invoke (cameraOpenCallback, cameraId, error);
}
//==============================================================================
@ -2955,8 +2953,7 @@ private:
{
JUCE_CAMERA_LOG ("notifyPictureTaken()");
if (pictureTakenCallback != nullptr)
pictureTakenCallback (image);
NullCheckedInvocation::invoke (pictureTakenCallback, image);
}
void triggerStillPictureCapture()

View file

@ -1155,14 +1155,9 @@ private:
JUCE_CAMERA_LOG ("cameraSessionRuntimeError(), error = " + error);
if (! notifiedOfCameraOpening)
{
cameraOpenCallback ({}, error);
}
else
{
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (error);
}
NullCheckedInvocation::invoke (owner.onErrorOccurred, error);
}
void callListeners (const Image& image)
@ -1178,8 +1173,7 @@ private:
{
JUCE_CAMERA_LOG ("notifyPictureTaken()");
if (pictureTakenCallback != nullptr)
pictureTakenCallback (image);
NullCheckedInvocation::invoke (pictureTakenCallback, image);
}
//==============================================================================

View file

@ -523,8 +523,8 @@ private:
MessageManager::callAsync ([weakRef = WeakReference<Pimpl> { this }, image]() mutable
{
if (weakRef != nullptr && weakRef->pictureTakenCallback != nullptr)
weakRef->pictureTakenCallback (image);
if (weakRef != nullptr)
NullCheckedInvocation::invoke (weakRef->pictureTakenCallback, image);
});
}
@ -551,8 +551,7 @@ private:
{
JUCE_CAMERA_LOG ("cameraSessionRuntimeError(), error = " + error);
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (error);
NullCheckedInvocation::invoke (owner.onErrorOccurred, error);
}
//==============================================================================

View file

@ -245,9 +245,7 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster
if (weakRef == nullptr)
return;
if (weakRef->pictureTakenCallback != nullptr)
weakRef->pictureTakenCallback (image);
NullCheckedInvocation::invoke (weakRef->pictureTakenCallback, image);
weakRef->pictureTakenCallback = nullptr;
});
}

View file

@ -1681,8 +1681,7 @@ private:
if (weakThis == nullptr)
return;
if (weakThis->owner.owner.onGlobalMediaVolumeChanged != nullptr)
weakThis->owner.owner.onGlobalMediaVolumeChanged();
NullCheckedInvocation::invoke (weakThis->owner.owner.onGlobalMediaVolumeChanged);
});
}
@ -1723,20 +1722,17 @@ private:
void errorOccurred (const String& errorMessage)
{
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (errorMessage);
NullCheckedInvocation::invoke (owner.onErrorOccurred, errorMessage);
}
void playbackStarted()
{
if (owner.onPlaybackStarted != nullptr)
owner.onPlaybackStarted();
NullCheckedInvocation::invoke (owner.onPlaybackStarted);
}
void playbackStopped()
{
if (owner.onPlaybackStopped != nullptr)
owner.onPlaybackStopped();
NullCheckedInvocation::invoke (owner.onPlaybackStopped);
}
//==============================================================================

View file

@ -810,20 +810,17 @@ private:
void errorOccurred (const String& errorMessage)
{
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (errorMessage);
NullCheckedInvocation::invoke (owner.onErrorOccurred, errorMessage);
}
void playbackStarted()
{
if (owner.onPlaybackStarted != nullptr)
owner.onPlaybackStarted();
NullCheckedInvocation::invoke (owner.onPlaybackStarted);
}
void playbackStopped()
{
if (owner.onPlaybackStopped != nullptr)
owner.onPlaybackStopped();
NullCheckedInvocation::invoke (owner.onPlaybackStopped);
}
void playbackReachedEndTime()

View file

@ -322,20 +322,17 @@ struct VideoComponent::Pimpl : public Component,
void playbackStarted()
{
if (owner.onPlaybackStarted != nullptr)
owner.onPlaybackStarted();
NullCheckedInvocation::invoke (owner.onPlaybackStarted);
}
void playbackStopped()
{
if (owner.onPlaybackStopped != nullptr)
owner.onPlaybackStopped();
NullCheckedInvocation::invoke (owner.onPlaybackStopped);
}
void errorOccurred (const String& errorMessage)
{
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (errorMessage);
NullCheckedInvocation::invoke (owner.onErrorOccurred, errorMessage);
}
File currentFile;