diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-18 01:32:57 +0100 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2021-12-18 01:32:57 +0100 |
commit | 106ece8407806a70e8327b15178668daae003fc2 (patch) | |
tree | d4a941f2c7058d5d6a26217402c7380c1335f962 | |
parent | af8c864f72b0beafbd63c063bf257069af830b21 (diff) | |
download | messenger-gtk-106ece8407806a70e8327b15178668daae003fc2.tar.gz messenger-gtk-106ece8407806a70e8327b15178668daae003fc2.zip |
Adjusted error handling of zbar
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r-- | src/ui/new_contact.c | 33 | ||||
-rw-r--r-- | src/ui/new_contact.h | 1 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/ui/new_contact.c b/src/ui/new_contact.c index 5a74089..c193629 100644 --- a/src/ui/new_contact.c +++ b/src/ui/new_contact.c | |||
@@ -147,6 +147,28 @@ render_image: | |||
147 | return FALSE; | 147 | return FALSE; |
148 | } | 148 | } |
149 | 149 | ||
150 | static void | ||
151 | _disable_video_processing(UI_NEW_CONTACT_Handle *handle) | ||
152 | { | ||
153 | if (!(handle->video)) | ||
154 | return; | ||
155 | |||
156 | const zbar_error_t error_code = zbar_video_get_error_code(handle->video); | ||
157 | |||
158 | if (ZBAR_OK != error_code) | ||
159 | { | ||
160 | const char *error_msg = zbar_video_error_string(handle->video, 0); | ||
161 | |||
162 | if (error_msg) | ||
163 | fprintf(stderr, "%s", error_msg); | ||
164 | else | ||
165 | fprintf(stderr, "ERROR: Unknown error with zbar (%d)\n", | ||
166 | (int) error_code); | ||
167 | } | ||
168 | |||
169 | handle->idle_processing = 0; | ||
170 | } | ||
171 | |||
150 | static gboolean | 172 | static gboolean |
151 | idle_video_processing(gpointer user_data) | 173 | idle_video_processing(gpointer user_data) |
152 | { | 174 | { |
@@ -158,7 +180,10 @@ idle_video_processing(gpointer user_data) | |||
158 | zbar_image_t *image = zbar_video_next_image(handle->video); | 180 | zbar_image_t *image = zbar_video_next_image(handle->video); |
159 | 181 | ||
160 | if (!image) | 182 | if (!image) |
161 | return TRUE; | 183 | { |
184 | _disable_video_processing(handle); | ||
185 | return FALSE; | ||
186 | } | ||
162 | 187 | ||
163 | GString *scan_result = NULL; | 188 | GString *scan_result = NULL; |
164 | 189 | ||
@@ -226,10 +251,16 @@ _ui_new_contact_video_thread(void *args) | |||
226 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) args; | 251 | UI_NEW_CONTACT_Handle *handle = (UI_NEW_CONTACT_Handle*) args; |
227 | 252 | ||
228 | if (0 != zbar_video_open(handle->video, "")) | 253 | if (0 != zbar_video_open(handle->video, "")) |
254 | { | ||
255 | _disable_video_processing(handle); | ||
229 | return NULL; | 256 | return NULL; |
257 | } | ||
230 | 258 | ||
231 | if (0 != zbar_video_enable(handle->video, 1)) | 259 | if (0 != zbar_video_enable(handle->video, 1)) |
260 | { | ||
261 | _disable_video_processing(handle); | ||
232 | return NULL; | 262 | return NULL; |
263 | } | ||
233 | 264 | ||
234 | zbar_image_scanner_set_config( | 265 | zbar_image_scanner_set_config( |
235 | handle->scanner, | 266 | handle->scanner, |
diff --git a/src/ui/new_contact.h b/src/ui/new_contact.h index ae1c7f3..18bb042 100644 --- a/src/ui/new_contact.h +++ b/src/ui/new_contact.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include "messenger.h" | 28 | #include "messenger.h" |
29 | 29 | ||
30 | #include <cairo/cairo.h> | ||
30 | #include <gdk/gdkpixbuf.h> | 31 | #include <gdk/gdkpixbuf.h> |
31 | #include <pthread.h> | 32 | #include <pthread.h> |
32 | #include <zbar.h> | 33 | #include <zbar.h> |