[gdk-pixbuf] QTIF: assert and assume that the module callbacks are non-NULL
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] QTIF: assert and assume that the module callbacks are non-NULL
- Date: Tue, 7 Jan 2020 14:31:38 +0000 (UTC)
commit 31ac03720ff35e91ebd36db02a0e970bfde5a800
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Nov 29 07:04:16 2017 -0600
QTIF: assert and assume that the module callbacks are non-NULL
gdk-pixbuf/io-qtif.c | 58 ++++++++++++++++++++--------------------------------
1 file changed, 22 insertions(+), 36 deletions(-)
---
diff --git a/gdk-pixbuf/io-qtif.c b/gdk-pixbuf/io-qtif.c
index 79fd4ffa9..aaa483611 100644
--- a/gdk-pixbuf/io-qtif.c
+++ b/gdk-pixbuf/io-qtif.c
@@ -256,6 +256,10 @@ static gpointer gdk_pixbuf__qtif_image_begin_load (GdkPixbufModuleSizeFunc size_
{
QTIFContext *context;
+ g_assert (size_func != NULL);
+ g_assert (prepare_func != NULL);
+ g_assert (update_func != NULL);
+
/* Create context struct. */
context = g_new0(QTIFContext, 1);
if(context == NULL)
@@ -329,24 +333,15 @@ static gboolean gdk_pixbuf__qtif_image_create_loader (QTIFContext *context, GErr
/* Connect signals. */
context->cb_prepare_count = 0;
context->cb_update_count = 0;
- if(context->size_func != NULL)
- {
- g_signal_connect(context->loader, "size-prepared",
- G_CALLBACK(gdk_pixbuf__qtif_cb_size_prepared),
- context);
- }
- if(context->prepare_func != NULL)
- {
- g_signal_connect(context->loader, "area-prepared",
- G_CALLBACK(gdk_pixbuf__qtif_cb_area_prepared),
- context);
- }
- if(context->update_func != NULL)
- {
- g_signal_connect(context->loader, "area-updated",
- G_CALLBACK(gdk_pixbuf__qtif_cb_area_updated),
- context);
- }
+ g_signal_connect(context->loader, "size-prepared",
+ G_CALLBACK(gdk_pixbuf__qtif_cb_size_prepared),
+ context);
+ g_signal_connect(context->loader, "area-prepared",
+ G_CALLBACK(gdk_pixbuf__qtif_cb_area_prepared),
+ context);
+ g_signal_connect(context->loader, "area-updated",
+ G_CALLBACK(gdk_pixbuf__qtif_cb_area_updated),
+ context);
return TRUE;
}
@@ -384,12 +379,12 @@ static gboolean gdk_pixbuf__qtif_image_free_loader (QTIFContext *context, GError
if(pixbuf != NULL)
{
/* Callback functions should be called for at least once. */
- if((context->prepare_func != NULL) && (context->cb_prepare_count == 0))
+ if(context->cb_prepare_count == 0)
{
(context->prepare_func)(pixbuf, NULL, context->user_data);
}
- if((context->update_func != NULL) && (context->cb_update_count == 0))
+ if(context->cb_update_count == 0)
{
gint width;
gint height;
@@ -542,22 +537,16 @@ static void gdk_pixbuf__qtif_cb_size_prepared(GdkPixbufLoader *loader,
gpointer user_data)
{
QTIFContext *context = (QTIFContext *)user_data;
- if((context != NULL) && (context->size_func != NULL))
- {
- (context->size_func)(&width, &height, context->user_data);
- context->cb_prepare_count++;
- }
+ (context->size_func)(&width, &height, context->user_data);
+ context->cb_prepare_count++;
}
static void gdk_pixbuf__qtif_cb_area_prepared(GdkPixbufLoader *loader, gpointer user_data)
{
QTIFContext *context = (QTIFContext *)user_data;
- if((loader != NULL) && (context != NULL) && (context->prepare_func != NULL))
- {
- GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(context->loader);
- (context->prepare_func)(pixbuf, NULL, context->user_data);
- context->cb_update_count++;
- }
+ GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(context->loader);
+ (context->prepare_func)(pixbuf, NULL, context->user_data);
+ context->cb_update_count++;
}
static void gdk_pixbuf__qtif_cb_area_updated(GdkPixbufLoader *loader,
@@ -568,11 +557,8 @@ static void gdk_pixbuf__qtif_cb_area_updated(GdkPixbufLoader *loader,
gpointer user_data)
{
QTIFContext *context = (QTIFContext *)user_data;
- if((loader != NULL) && (context != NULL) && (context->update_func != NULL))
- {
- GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(context->loader);
- (context->update_func)(pixbuf, x, y, width, height, context->user_data);
- }
+ GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(context->loader);
+ (context->update_func)(pixbuf, x, y, width, height, context->user_data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]