diff options
author | Ondrej Holy <oholy@redhat.com> | 2017-10-20 16:19:05 +0200 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2018-03-26 10:15:31 +0200 |
commit | 05c86d3fdc24865176973a4aca16cbc3cb841a8a (patch) | |
tree | 456e4a12818a3b7f1fb397c925bf5ec873d73635 /panels | |
parent | 4eb2ab802928ec8ed55e0a1c3791e09c3077ed0e (diff) | |
download | gnome-control-center-05c86d3fdc24865176973a4aca16cbc3cb841a8a.tar.gz |
user-accounts: Prevent freeze caused by external cameras
cheese_camera_device_monitor_new freezes the whole panel when opening
for a couple of seconds if external camera is connected. This is not
acceptable. Probably it is bug in kernel. Let's use GAsyncInitable if
available.
Bump the cheese dependency accordingly.
https://bugzilla.gnome.org/show_bug.cgi?id=783789
Diffstat (limited to 'panels')
-rw-r--r-- | panels/user-accounts/um-photo-dialog.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/panels/user-accounts/um-photo-dialog.c b/panels/user-accounts/um-photo-dialog.c index 2287e3e69..1219ef21f 100644 --- a/panels/user-accounts/um-photo-dialog.c +++ b/panels/user-accounts/um-photo-dialog.c @@ -52,6 +52,7 @@ struct _UmPhotoDialog { #ifdef HAVE_CHEESE CheeseCameraDeviceMonitor *monitor; + GCancellable *cancellable; guint num_cameras; #endif /* HAVE_CHEESE */ @@ -370,6 +371,32 @@ create_face_widget (gpointer item, return image; } +#ifdef HAVE_CHEESE +static void +setup_cheese_camera_device_monitor (UmPhotoDialog *um) +{ + g_signal_connect (G_OBJECT (um->monitor), "added", G_CALLBACK (device_added), um); + g_signal_connect (G_OBJECT (um->monitor), "removed", G_CALLBACK (device_removed), um); + cheese_camera_device_monitor_coldplug (um->monitor); +} + +static void +cheese_camera_device_monitor_new_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + UmPhotoDialog *um = user_data; + GObject *ret; + + ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, NULL); + if (ret == NULL) + return; + + um->monitor = CHEESE_CAMERA_DEVICE_MONITOR (ret); + setup_cheese_camera_device_monitor (um); +} +#endif /* HAVE_CHEESE */ + static void setup_photo_popup (UmPhotoDialog *um) { @@ -445,12 +472,13 @@ setup_photo_popup (UmPhotoDialog *um) #ifdef HAVE_CHEESE gtk_widget_set_visible (um->take_picture_button, TRUE); - um->monitor = cheese_camera_device_monitor_new (); - g_signal_connect (G_OBJECT (um->monitor), "added", - G_CALLBACK (device_added), um); - g_signal_connect (G_OBJECT (um->monitor), "removed", - G_CALLBACK (device_removed), um); - cheese_camera_device_monitor_coldplug (um->monitor); + um->cancellable = g_cancellable_new (); + g_async_initable_new_async (CHEESE_TYPE_CAMERA_DEVICE_MONITOR, + G_PRIORITY_DEFAULT, + um->cancellable, + cheese_camera_device_monitor_new_cb, + um, + NULL); #endif /* HAVE_CHEESE */ } @@ -509,6 +537,8 @@ um_photo_dialog_dispose (GObject *object) g_clear_object (&um->thumb_factory); #ifdef HAVE_CHEESE + g_cancellable_cancel (um->cancellable); + g_clear_object (&um->cancellable); g_clear_object (&um->monitor); #endif g_clear_object (&um->user); |