Browse Source

Use NullCheckedInvocation in more places

v7.0.9
Tom Poole 2 years ago
parent
commit
ff0cb4ad5b
46 changed files with 145 additions and 258 deletions
  1. +5
    -5
      examples/Assets/DSPDemos_Common.h
  2. +2
    -2
      examples/Audio/MidiDemo.h
  3. +5
    -5
      examples/DemoRunner/Builds/Android/app/src/main/assets/DSPDemos_Common.h
  4. +1
    -1
      examples/GUI/CameraDemo.h
  5. +6
    -6
      examples/GUI/OpenGLAppDemo.h
  6. +10
    -10
      examples/GUI/OpenGLDemo.h
  7. +2
    -4
      examples/Plugins/MidiLoggerPluginDemo.h
  8. +1
    -1
      examples/Plugins/ReaperEmbeddedViewPluginDemo.h
  9. +1
    -1
      examples/Utilities/AnalyticsCollectionDemo.h
  10. +1
    -1
      examples/Utilities/ChildProcessDemo.h
  11. +1
    -1
      examples/Utilities/ValueTreesDemo.h
  12. +3
    -3
      examples/Utilities/XMLandJSONDemo.h
  13. +5
    -5
      extras/AudioPluginHost/Builds/Android/app/src/main/assets/DSPDemos_Common.h
  14. +22
    -50
      extras/Projucer/Source/Application/jucer_MainWindow.cpp
  15. +11
    -28
      extras/Projucer/Source/CodeEditor/jucer_OpenDocumentManager.cpp
  16. +2
    -5
      extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp
  17. +1
    -2
      modules/juce_audio_devices/native/juce_JackAudio_linux.cpp
  18. +1
    -1
      modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp
  19. +5
    -12
      modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp
  20. +6
    -7
      modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp
  21. +2
    -2
      modules/juce_audio_processors/format_types/juce_VST3Common.h
  22. +1
    -2
      modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp
  23. +1
    -2
      modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h
  24. +1
    -2
      modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp
  25. +2
    -4
      modules/juce_events/native/juce_MessageManager_mac.mm
  26. +1
    -2
      modules/juce_events/native/juce_Messaging_windows.cpp
  27. +1
    -2
      modules/juce_graphics/fonts/juce_Font.cpp
  28. +2
    -4
      modules/juce_gui_basics/buttons/juce_Button.cpp
  29. +5
    -13
      modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp
  30. +2
    -4
      modules/juce_gui_basics/layout/juce_SidePanel.cpp
  31. +1
    -2
      modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp
  32. +1
    -2
      modules/juce_gui_basics/native/juce_Windowing_mac.mm
  33. +5
    -6
      modules/juce_gui_basics/native/juce_Windowing_windows.cpp
  34. +1
    -2
      modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp
  35. +1
    -2
      modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp
  36. +1
    -2
      modules/juce_gui_basics/widgets/juce_ComboBox.cpp
  37. +3
    -6
      modules/juce_gui_basics/widgets/juce_Label.cpp
  38. +3
    -6
      modules/juce_gui_basics/widgets/juce_Slider.cpp
  39. +1
    -2
      modules/juce_osc/osc/juce_OSCReceiver.cpp
  40. +3
    -6
      modules/juce_video/native/juce_CameraDevice_android.h
  41. +2
    -8
      modules/juce_video/native/juce_CameraDevice_ios.h
  42. +3
    -4
      modules/juce_video/native/juce_CameraDevice_mac.h
  43. +1
    -3
      modules/juce_video/native/juce_CameraDevice_windows.h
  44. +4
    -8
      modules/juce_video/native/juce_Video_android.h
  45. +3
    -6
      modules/juce_video/native/juce_Video_mac.h
  46. +3
    -6
      modules/juce_video/native/juce_Video_windows.h

+ 5
- 5
examples/Assets/DSPDemos_Common.h View File

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


+ 2
- 2
examples/Audio/MidiDemo.h View File

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


+ 5
- 5
examples/DemoRunner/Builds/Android/app/src/main/assets/DSPDemos_Common.h View File

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


+ 1
- 1
examples/GUI/CameraDemo.h View File

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


+ 6
- 6
examples/GUI/OpenGLAppDemo.h View File

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


+ 10
- 10
examples/GUI/OpenGLDemo.h View File

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


+ 2
- 4
examples/Plugins/MidiLoggerPluginDemo.h View File

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


+ 1
- 1
examples/Plugins/ReaperEmbeddedViewPluginDemo.h View File

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


+ 1
- 1
examples/Utilities/AnalyticsCollectionDemo.h View File

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


+ 1
- 1
examples/Utilities/ChildProcessDemo.h View File

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


+ 1
- 1
examples/Utilities/ValueTreesDemo.h View File

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


+ 3
- 3
examples/Utilities/XMLandJSONDemo.h View File

@@ -312,12 +312,12 @@ private:
{ {
std::unique_ptr<XmlElement> openness; std::unique_ptr<XmlElement> openness;
if (rootItem.get() != nullptr)
if (rootItem != nullptr)
openness = rootItem->getOpennessState(); openness = rootItem->getOpennessState();
createNewRootNode(); createNewRootNode();
if (openness.get() != nullptr && rootItem.get() != nullptr)
if (openness != nullptr && rootItem != nullptr)
rootItem->restoreOpennessState (*openness); 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 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.clear();
errorMessage.setVisible (! errorMessage.isEmpty()); errorMessage.setVisible (! errorMessage.isEmpty());


+ 5
- 5
extras/AudioPluginHost/Builds/Android/app/src/main/assets/DSPDemos_Common.h View File

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


+ 22
- 50
extras/Projucer/Source/Application/jucer_MainWindow.cpp View File

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


+ 11
- 28
extras/Projucer/Source/CodeEditor/jucer_OpenDocumentManager.cpp View File

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


+ 2
- 5
extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp View File

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


+ 1
- 2
modules/juce_audio_devices/native/juce_JackAudio_linux.cpp View File

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


+ 1
- 1
modules/juce_audio_plugin_client/juce_audio_plugin_client_Standalone.cpp View File

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


+ 5
- 12
modules/juce_audio_plugin_client/juce_audio_plugin_client_VST2.cpp View File

@@ -466,8 +466,7 @@ public:
} }
// Send VST events to the host. // 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 #elif JUCE_DEBUG
/* This assertion is caused when you've added some events to the /* This assertion is caused when you've added some events to the
midiMessages array in your processBlock() method, which usually means midiMessages array in your processBlock() method, which usually means
@@ -545,10 +544,7 @@ public:
some hosts rely on this behaviour. some hosts rely on this behaviour.
*/ */
if (vstEffect.flags & Vst2::effFlagsIsSynth || JucePlugin_WantsMidiInput || JucePlugin_IsMidiEffect) 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() if (detail::PluginUtilities::getHostType().isAbletonLive()
&& hostCallback != nullptr && hostCallback != nullptr
@@ -697,20 +693,17 @@ public:
return; 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 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 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 void parameterValueChanged (int, float newValue) override


+ 6
- 7
modules/juce_audio_processors/format_types/juce_LADSPAPluginFormat.cpp View File

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


+ 2
- 2
modules/juce_audio_processors/format_types/juce_VST3Common.h View File

@@ -100,8 +100,8 @@ public:
{ {
const auto toReturn = result.extract (obj); 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; return toReturn;
} }


+ 1
- 2
modules/juce_audio_processors/utilities/juce_ParameterAttachments.cpp View File

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


+ 1
- 2
modules/juce_data_structures/values/juce_ValueTreePropertyWithDefault.h View File

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


+ 1
- 2
modules/juce_events/interprocess/juce_NetworkServiceDiscovery.cpp View File

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


+ 2
- 4
modules/juce_events/native/juce_MessageManager_mac.mm View File

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


+ 1
- 2
modules/juce_events/native/juce_Messaging_windows.cpp View File

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


+ 1
- 2
modules/juce_graphics/fonts/juce_Font.cpp View File

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


+ 2
- 4
modules/juce_gui_basics/buttons/juce_Button.cpp View File

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


+ 5
- 13
modules/juce_gui_basics/layout/juce_MultiDocumentPanel.cpp View File

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


+ 2
- 4
modules/juce_gui_basics/layout/juce_SidePanel.cpp View File

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


+ 1
- 2
modules/juce_gui_basics/native/juce_DragAndDrop_linux.cpp View File

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


+ 1
- 2
modules/juce_gui_basics/native/juce_Windowing_mac.mm View File

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


+ 5
- 6
modules/juce_gui_basics/native/juce_Windowing_windows.cpp View File

@@ -423,8 +423,7 @@ static void setDPIAwareness()
&& SUCCEEDED (setProcessDPIAwareness (DPI_Awareness::DPI_Awareness_System_Aware))) && SUCCEEDED (setProcessDPIAwareness (DPI_Awareness::DPI_Awareness_System_Aware)))
return; return;
if (setProcessDPIAware != nullptr)
setProcessDPIAware();
NullCheckedInvocation::invoke (setProcessDPIAware);
} }
static bool isPerMonitorDPIAwareProcess() static bool isPerMonitorDPIAwareProcess()
@@ -3065,8 +3064,8 @@ private:
// This avoids a rare stuck-button problem when focus is lost unexpectedly, but must // 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 // 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.. // 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(); updateKeyModifiers();
@@ -3955,8 +3954,8 @@ public:
{ {
// Ensure that non-client areas are scaled for per-monitor DPI awareness v1 - can't // 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 // 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)) if (auto* peer = getOwnerOfWindow (h))
{ {


+ 1
- 2
modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp View File

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


+ 1
- 2
modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp View File

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


+ 1
- 2
modules/juce_gui_basics/widgets/juce_ComboBox.cpp View File

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


+ 3
- 6
modules/juce_gui_basics/widgets/juce_Label.cpp View File

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


+ 3
- 6
modules/juce_gui_basics/widgets/juce_Slider.cpp View File

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


+ 1
- 2
modules/juce_osc/osc/juce_OSCReceiver.cpp View File

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


+ 3
- 6
modules/juce_video/native/juce_CameraDevice_android.h View File

@@ -2932,16 +2932,14 @@ private:
void cameraDeviceError (const String& error) void cameraDeviceError (const String& error)
{ {
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (error);
NullCheckedInvocation::invoke (owner.onErrorOccurred, error);
} }
void invokeCameraOpenCallback (const String& error) void invokeCameraOpenCallback (const String& error)
{ {
JUCE_CAMERA_LOG ("invokeCameraOpenCallback(), error = " + 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()"); JUCE_CAMERA_LOG ("notifyPictureTaken()");
if (pictureTakenCallback != nullptr)
pictureTakenCallback (image);
NullCheckedInvocation::invoke (pictureTakenCallback, image);
} }
void triggerStillPictureCapture() void triggerStillPictureCapture()


+ 2
- 8
modules/juce_video/native/juce_CameraDevice_ios.h View File

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


+ 3
- 4
modules/juce_video/native/juce_CameraDevice_mac.h View File

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


+ 1
- 3
modules/juce_video/native/juce_CameraDevice_windows.h View File

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


+ 4
- 8
modules/juce_video/native/juce_Video_android.h View File

@@ -1681,8 +1681,7 @@ private:
if (weakThis == nullptr) if (weakThis == nullptr)
return; 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) void errorOccurred (const String& errorMessage)
{ {
if (owner.onErrorOccurred != nullptr)
owner.onErrorOccurred (errorMessage);
NullCheckedInvocation::invoke (owner.onErrorOccurred, errorMessage);
} }
void playbackStarted() void playbackStarted()
{ {
if (owner.onPlaybackStarted != nullptr)
owner.onPlaybackStarted();
NullCheckedInvocation::invoke (owner.onPlaybackStarted);
} }
void playbackStopped() void playbackStopped()
{ {
if (owner.onPlaybackStopped != nullptr)
owner.onPlaybackStopped();
NullCheckedInvocation::invoke (owner.onPlaybackStopped);
} }
//============================================================================== //==============================================================================


+ 3
- 6
modules/juce_video/native/juce_Video_mac.h View File

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


+ 3
- 6
modules/juce_video/native/juce_Video_windows.h View File

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


Loading…
Cancel
Save