From 5f4ac65251bc8985e10c6598ed91836310494e35 Mon Sep 17 00:00:00 2001 From: Kongfa Waroros Date: Sun, 14 Mar 2021 16:47:21 +0700 Subject: [PATCH] Check if an input image wasn't Image on several functions in CameraFeed (cherry picked from commit 916e576021ca6bd25171105faa2e13341fc1c82f) --- servers/camera/camera_feed.cpp | 10 +++++++--- servers/camera/camera_feed.h | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp index 65f876e4fd3..e326bc9af5a 100644 --- a/servers/camera/camera_feed.cpp +++ b/servers/camera/camera_feed.cpp @@ -172,7 +172,8 @@ CameraFeed::~CameraFeed() { vs->free(texture[CameraServer::FEED_CBCR_IMAGE]); } -void CameraFeed::set_RGB_img(Ref p_rgb_img) { +void CameraFeed::set_RGB_img(const Ref &p_rgb_img) { + ERR_FAIL_COND(p_rgb_img.is_null()); if (active) { VisualServer *vs = VisualServer::get_singleton(); @@ -192,7 +193,8 @@ void CameraFeed::set_RGB_img(Ref p_rgb_img) { } } -void CameraFeed::set_YCbCr_img(Ref p_ycbcr_img) { +void CameraFeed::set_YCbCr_img(const Ref &p_ycbcr_img) { + ERR_FAIL_COND(p_ycbcr_img.is_null()); if (active) { VisualServer *vs = VisualServer::get_singleton(); @@ -212,7 +214,9 @@ void CameraFeed::set_YCbCr_img(Ref p_ycbcr_img) { } } -void CameraFeed::set_YCbCr_imgs(Ref p_y_img, Ref p_cbcr_img) { +void CameraFeed::set_YCbCr_imgs(const Ref &p_y_img, const Ref &p_cbcr_img) { + ERR_FAIL_COND(p_y_img.is_null()); + ERR_FAIL_COND(p_cbcr_img.is_null()); if (active) { VisualServer *vs = VisualServer::get_singleton(); diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h index fc41af55aca..44efbc10d12 100644 --- a/servers/camera/camera_feed.h +++ b/servers/camera/camera_feed.h @@ -100,9 +100,9 @@ public: virtual ~CameraFeed(); FeedDataType get_datatype() const; - void set_RGB_img(Ref p_rgb_img); - void set_YCbCr_img(Ref p_ycbcr_img); - void set_YCbCr_imgs(Ref p_y_img, Ref p_cbcr_img); + void set_RGB_img(const Ref &p_rgb_img); + void set_YCbCr_img(const Ref &p_ycbcr_img); + void set_YCbCr_imgs(const Ref &p_y_img, const Ref &p_cbcr_img); void allocate_texture(int p_width, int p_height, Image::Format p_format, VisualServer::TextureType p_texture_type, FeedDataType p_data_type); virtual bool activate_feed();