1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Use NullCheckedInvocation in more places

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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