diff --git a/examples/Assets/DSPDemos_Common.h b/examples/Assets/DSPDemos_Common.h index 6e2bf3e836..e24eb78a20 100644 --- a/examples/Assets/DSPDemos_Common.h +++ b/examples/Assets/DSPDemos_Common.h @@ -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()); } diff --git a/examples/Audio/MidiDemo.h b/examples/Audio/MidiDemo.h index 821610f47f..27524c92a3 100644 --- a/examples/Audio/MidiDemo.h +++ b/examples/Audio/MidiDemo.h @@ -311,7 +311,7 @@ private: { SparseSet 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 (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); } diff --git a/examples/DemoRunner/Builds/Android/app/src/main/assets/DSPDemos_Common.h b/examples/DemoRunner/Builds/Android/app/src/main/assets/DSPDemos_Common.h index 6e2bf3e836..e24eb78a20 100644 --- a/examples/DemoRunner/Builds/Android/app/src/main/assets/DSPDemos_Common.h +++ b/examples/DemoRunner/Builds/Android/app/src/main/assets/DSPDemos_Common.h @@ -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()); } diff --git a/examples/GUI/CameraDemo.h b/examples/GUI/CameraDemo.h index 58d3e2e70f..b91073df16 100644 --- a/examples/GUI/CameraDemo.h +++ b/examples/GUI/CameraDemo.h @@ -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()) diff --git a/examples/GUI/OpenGLAppDemo.h b/examples/GUI/OpenGLAppDemo.h index e36626fdbb..dbd3689734 100644 --- a/examples/GUI/OpenGLAppDemo.h +++ b/examples/GUI/OpenGLAppDemo.h @@ -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 position, normal, sourceColour, textureCoordIn; diff --git a/examples/GUI/OpenGLDemo.h b/examples/GUI/OpenGLDemo.h index 9bfe8bcacd..4dd5d0e92f 100644 --- a/examples/GUI/OpenGLDemo.h +++ b/examples/GUI/OpenGLDemo.h @@ -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 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); diff --git a/examples/Plugins/MidiLoggerPluginDemo.h b/examples/Plugins/MidiLoggerPluginDemo.h index d45b500cda..40b9f38350 100644 --- a/examples/Plugins/MidiLoggerPluginDemo.h +++ b/examples/Plugins/MidiLoggerPluginDemo.h @@ -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]; } diff --git a/examples/Plugins/ReaperEmbeddedViewPluginDemo.h b/examples/Plugins/ReaperEmbeddedViewPluginDemo.h index 3feb61c651..313a6dc0d8 100644 --- a/examples/Plugins/ReaperEmbeddedViewPluginDemo.h +++ b/examples/Plugins/ReaperEmbeddedViewPluginDemo.h @@ -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); } diff --git a/examples/Utilities/AnalyticsCollectionDemo.h b/examples/Utilities/AnalyticsCollectionDemo.h index 03ad3188f0..1b6ec2c937 100644 --- a/examples/Utilities/AnalyticsCollectionDemo.h +++ b/examples/Utilities/AnalyticsCollectionDemo.h @@ -199,7 +199,7 @@ public: shouldExit = true; - if (webStream.get() != nullptr) + if (webStream != nullptr) webStream->cancel(); } diff --git a/examples/Utilities/ChildProcessDemo.h b/examples/Utilities/ChildProcessDemo.h index 226f361adc..4f8770b512 100644 --- a/examples/Utilities/ChildProcessDemo.h +++ b/examples/Utilities/ChildProcessDemo.h @@ -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!"); diff --git a/examples/Utilities/ValueTreesDemo.h b/examples/Utilities/ValueTreesDemo.h index b172700e08..50853fb17e 100644 --- a/examples/Utilities/ValueTreesDemo.h +++ b/examples/Utilities/ValueTreesDemo.h @@ -129,7 +129,7 @@ public: } } - if (oldOpenness.get() != nullptr) + if (oldOpenness != nullptr) treeView.restoreOpennessState (*oldOpenness, false); } } diff --git a/examples/Utilities/XMLandJSONDemo.h b/examples/Utilities/XMLandJSONDemo.h index 8362bccda3..cc603e3519 100644 --- a/examples/Utilities/XMLandJSONDemo.h +++ b/examples/Utilities/XMLandJSONDemo.h @@ -312,12 +312,12 @@ private: { std::unique_ptr 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()); diff --git a/extras/AudioPluginHost/Builds/Android/app/src/main/assets/DSPDemos_Common.h b/extras/AudioPluginHost/Builds/Android/app/src/main/assets/DSPDemos_Common.h index 6e2bf3e836..e24eb78a20 100644 --- a/extras/AudioPluginHost/Builds/Android/app/src/main/assets/DSPDemos_Common.h +++ b/extras/AudioPluginHost/Builds/Android/app/src/main/assets/DSPDemos_Common.h @@ -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()); } diff --git a/extras/Projucer/Source/Application/jucer_MainWindow.cpp b/extras/Projucer/Source/Application/jucer_MainWindow.cpp index 031cf9a792..9521e8c2ed 100644 --- a/extras/Projucer/Source/Application/jucer_MainWindow.cpp +++ b/extras/Projucer/Source/Application/jucer_MainWindow.cpp @@ -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 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 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 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 callback return; } - if (callback != nullptr) - callback (false); + NullCheckedInvocation::invoke (callback, false); } void MainWindow::openPIP (const File& pipFile, std::function callback) @@ -454,9 +444,7 @@ void MainWindow::openPIP (const File& pipFile, std::function 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 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 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 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 parent, { if (parent->windows.size() == 0) { - if (callback != nullptr) - callback (true); - + NullCheckedInvocation::invoke (callback, true); return; } @@ -759,9 +738,7 @@ static void askAllWindowsToCloseRecursive (WeakReference 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 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 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 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 call getFrontmostWindow()->openFile (file, [parent, callback] (bool openedSuccessfully) { - if (parent != nullptr && callback != nullptr) - callback (openedSuccessfully); + if (parent != nullptr) + NullCheckedInvocation::invoke (callback, openedSuccessfully); }); } diff --git a/extras/Projucer/Source/CodeEditor/jucer_OpenDocumentManager.cpp b/extras/Projucer/Source/CodeEditor/jucer_OpenDocumentManager.cpp index c11066b25b..a27df6574a 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_OpenDocumentManager.cpp +++ b/extras/Projucer/Source/CodeEditor/jucer_OpenDocumentManager.cpp @@ -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 parent, if (lastIndex < 0) { - if (callback != nullptr) - callback (true); - + NullCheckedInvocation::invoke (callback, true); return; } @@ -301,9 +289,7 @@ static void closeLastAsyncRecusrsive (WeakReference 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 callback) diff --git a/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp b/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp index 6695ef0048..098f4c9467 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp @@ -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); }); } diff --git a/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp b/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp index dbe0a4d0f6..6e86ecb301 100644 --- a/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp +++ b/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp @@ -517,8 +517,7 @@ private: if (oldCallback != nullptr) start (oldCallback); - if (notifyChannelsChanged != nullptr) - notifyChannelsChanged(); + NullCheckedInvocation::invoke (notifyChannelsChanged); } } diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp index 8b980cb83c..5a61223f19 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp @@ -120,7 +120,7 @@ public: //============================================================================== void systemRequestedQuit() override { - if (mainWindow.get() != nullptr) + if (mainWindow != nullptr) mainWindow->pluginHolder->savePluginState(); if (ModalComponentManager::getInstance()->cancelAllModalComponents()) diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp b/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp index 8ddec695f5..f61c2459a8 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp @@ -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 diff --git a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp index 275f2be8a8..a84521da12 100644 --- a/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp @@ -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); } diff --git a/modules/juce_audio_processors/format_types/juce_VST3Common.h b/modules/juce_audio_processors/format_types/juce_VST3Common.h index e4bb2c1b5b..221898b1b7 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -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; } diff --git a/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp b/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp index 3c092a16ec..f7a55e5c31 100644 --- a/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp +++ b/modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp @@ -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)); } //============================================================================== diff --git a/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h b/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h index c5a14a56df..214d2dcf44 100644 --- a/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h +++ b/modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h @@ -293,8 +293,7 @@ private: void valueChanged (Value&) override { - if (onDefaultChange != nullptr) - onDefaultChange(); + NullCheckedInvocation::invoke (onDefaultChange); } void referToWithDefault (ValueTree v, diff --git a/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp b/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp index add5e52170..5e986316b6 100644 --- a/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp +++ b/modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp @@ -134,8 +134,7 @@ std::vector NetworkServiceDiscovery::Available void NetworkServiceDiscovery::AvailableServiceList::handleAsyncUpdate() { - if (onChange != nullptr) - onChange(); + NullCheckedInvocation::invoke (onChange); } void NetworkServiceDiscovery::AvailableServiceList::handleMessage (const XmlElement& xml) diff --git a/modules/juce_events/native/juce_MessageManager_mac.mm b/modules/juce_events/native/juce_MessageManager_mac.mm index b0696430cb..e54f98a578 100644 --- a/modules/juce_events/native/juce_MessageManager_mac.mm +++ b/modules/juce_events/native/juce_MessageManager_mac.mm @@ -110,14 +110,12 @@ struct AppDelegateClass : public ObjCClass 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) diff --git a/modules/juce_events/native/juce_Messaging_windows.cpp b/modules/juce_events/native/juce_Messaging_windows.cpp index e011373b95..aeccc2509d 100644 --- a/modules/juce_events/native/juce_Messaging_windows.cpp +++ b/modules/juce_events/native/juce_Messaging_windows.cpp @@ -164,8 +164,7 @@ private: } if (message == WM_SETTINGCHANGE) - if (settingChangeCallback != nullptr) - settingChangeCallback(); + NullCheckedInvocation::invoke (settingChangeCallback); } return DefWindowProc (h, message, wParam, lParam); diff --git a/modules/juce_graphics/fonts/juce_Font.cpp b/modules/juce_graphics/fonts/juce_Font.cpp index 8eb2c9d372..4aa4182d7f 100644 --- a/modules/juce_graphics/fonts/juce_Font.cpp +++ b/modules/juce_graphics/fonts/juce_Font.cpp @@ -178,8 +178,7 @@ void Typeface::clearTypefaceCache() RenderingHelpers::SoftwareRendererSavedState::clearGlyphCache(); - if (clearOpenGLGlyphCache != nullptr) - clearOpenGLGlyphCache(); + NullCheckedInvocation::invoke (clearOpenGLGlyphCache); } //============================================================================== diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index 0dd5ce9f80..1536760f85 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -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); } //============================================================================== diff --git a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp index b711858cd4..4d907ecaec 100644 --- a/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp @@ -128,9 +128,7 @@ void MultiDocumentPanel::closeLastDocumentRecursive (SafePointercomponents.isEmpty()) { - if (callback != nullptr) - callback (true); - + NullCheckedInvocation::invoke (callback, true); return; } @@ -143,9 +141,7 @@ void MultiDocumentPanel::closeLastDocumentRecursive (SafePointercloseDocumentInternal (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 } diff --git a/modules/juce_gui_basics/layout/juce_SidePanel.cpp b/modules/juce_gui_basics/layout/juce_SidePanel.cpp index dfd36a45c9..7d05bfd3c7 100644 --- a/modules/juce_gui_basics/layout/juce_SidePanel.cpp +++ b/modules/juce_gui_basics/layout/juce_SidePanel.cpp @@ -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); diff --git a/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp b/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp index 6b48495a84..6eb0e12a33 100644 --- a/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp +++ b/modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp @@ -340,8 +340,7 @@ public: X11Symbols::getInstance()->xUngrabPointer (getDisplay(), CurrentTime); } - if (completionCallback != nullptr) - completionCallback(); + NullCheckedInvocation::invoke (completionCallback); dragging = false; } diff --git a/modules/juce_gui_basics/native/juce_Windowing_mac.mm b/modules/juce_gui_basics/native/juce_Windowing_mac.mm index 52efbe85c1..40a0a83e73 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_mac.mm +++ b/modules/juce_gui_basics/native/juce_Windowing_mac.mm @@ -410,8 +410,7 @@ struct DisplaySettingsChangeCallback : private DeletedAtShutdown static void displayReconfigurationCallback (CGDirectDisplayID, CGDisplayChangeSummaryFlags, void* userInfo) { if (auto* thisPtr = static_cast (userInfo)) - if (thisPtr->forceDisplayUpdate != nullptr) - thisPtr->forceDisplayUpdate(); + NullCheckedInvocation::invoke (thisPtr->forceDisplayUpdate); } std::function forceDisplayUpdate; diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index 9740c9f9ee..fc4b5b7dce 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -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)) { diff --git a/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp b/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp index bd81771ea8..22877c9b7f 100644 --- a/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp +++ b/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp @@ -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 XWindowSystem::getCurrentMousePosition() const diff --git a/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp b/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp index 12c9bcd7ef..474555f729 100644 --- a/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp +++ b/modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp @@ -334,8 +334,7 @@ void MultiChoicePropertyComponent::setExpanded (bool shouldBeExpanded) noexcept if (auto* propertyPanel = findParentComponentOfClass()) propertyPanel->resized(); - if (onHeightChange != nullptr) - onHeightChange(); + NullCheckedInvocation::invoke (onHeightChange); expandButton.setTransform (AffineTransform::rotation (expanded ? MathConstants::pi : MathConstants::twoPi, (float) expandButton.getBounds().getCentreX(), diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 21d64a4e11..e7aa618bb0 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -625,8 +625,7 @@ void ComboBox::handleAsyncUpdate() if (checker.shouldBailOut()) return; - if (onChange != nullptr) - onChange(); + NullCheckedInvocation::invoke (onChange); if (checker.shouldBailOut()) return; diff --git a/modules/juce_gui_basics/widgets/juce_Label.cpp b/modules/juce_gui_basics/widgets/juce_Label.cpp index 1e382b663b..8723041754 100644 --- a/modules/juce_gui_basics/widgets/juce_Label.cpp +++ b/modules/juce_gui_basics/widgets/juce_Label.cpp @@ -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); } //============================================================================== diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index efe8ec5b14..3d531fd486 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -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) diff --git a/modules/juce_osc/osc/juce_OSCReceiver.cpp b/modules/juce_osc/osc/juce_OSCReceiver.cpp index a855668ad2..3c6ce13bd7 100644 --- a/modules/juce_osc/osc/juce_OSCReceiver.cpp +++ b/modules/juce_osc/osc/juce_OSCReceiver.cpp @@ -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); } } diff --git a/modules/juce_video/native/juce_CameraDevice_android.h b/modules/juce_video/native/juce_CameraDevice_android.h index fd29bfb7bd..45a21ef5fe 100644 --- a/modules/juce_video/native/juce_CameraDevice_android.h +++ b/modules/juce_video/native/juce_CameraDevice_android.h @@ -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() diff --git a/modules/juce_video/native/juce_CameraDevice_ios.h b/modules/juce_video/native/juce_CameraDevice_ios.h index 5aeb6f7d46..02fc402070 100644 --- a/modules/juce_video/native/juce_CameraDevice_ios.h +++ b/modules/juce_video/native/juce_CameraDevice_ios.h @@ -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); } //============================================================================== diff --git a/modules/juce_video/native/juce_CameraDevice_mac.h b/modules/juce_video/native/juce_CameraDevice_mac.h index 659f0b1ac0..ddcba1f320 100644 --- a/modules/juce_video/native/juce_CameraDevice_mac.h +++ b/modules/juce_video/native/juce_CameraDevice_mac.h @@ -523,8 +523,8 @@ private: MessageManager::callAsync ([weakRef = WeakReference { 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); } //============================================================================== diff --git a/modules/juce_video/native/juce_CameraDevice_windows.h b/modules/juce_video/native/juce_CameraDevice_windows.h index 535c6a3d30..4ffbb4fe35 100644 --- a/modules/juce_video/native/juce_CameraDevice_windows.h +++ b/modules/juce_video/native/juce_CameraDevice_windows.h @@ -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; }); } diff --git a/modules/juce_video/native/juce_Video_android.h b/modules/juce_video/native/juce_Video_android.h index 0ffc092c3b..2109b2f4ce 100644 --- a/modules/juce_video/native/juce_Video_android.h +++ b/modules/juce_video/native/juce_Video_android.h @@ -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); } //============================================================================== diff --git a/modules/juce_video/native/juce_Video_mac.h b/modules/juce_video/native/juce_Video_mac.h index 7ca53cd441..6ca2d92d76 100644 --- a/modules/juce_video/native/juce_Video_mac.h +++ b/modules/juce_video/native/juce_Video_mac.h @@ -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() diff --git a/modules/juce_video/native/juce_Video_windows.h b/modules/juce_video/native/juce_Video_windows.h index 263b47e165..857bdfaf5c 100644 --- a/modules/juce_video/native/juce_Video_windows.h +++ b/modules/juce_video/native/juce_Video_windows.h @@ -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;