Submitted By: Douglas R. Reno Date: 2021-04-08 Initial Package Version: 3.38.0 Upstream Status: Applied Origin: MR 41 (https://gitlab.gnome.org/GNOME/cheese/-/merge_requests/41/) Description: Fixes building cheese with vala-0.52.x and later by converting from GLib.PtrArray to GLib.GenericArray. It also fixes some memory leaks along the way and an unnecessary reference increase. diff -Naurp cheese-3.38.0.orig/src/cheese-preferences.vala cheese-3.38.0/src/cheese-preferences.vala --- cheese-3.38.0.orig/src/cheese-preferences.vala 2020-09-15 06:22:10.055515300 -0500 +++ cheese-3.38.0/src/cheese-preferences.vala 2021-04-08 12:53:33.270717291 -0500 @@ -100,7 +100,7 @@ public PreferencesDialog (Cheese.Camera */ private void initialize_camera_devices () { - unowned GLib.PtrArray devices = camera.get_camera_devices (); + GLib.GenericArray devices = camera.get_camera_devices (); camera_model = new Gtk.ListStore (2, typeof (string), typeof (Cheese.CameraDevice)); source_combo.model = camera_model; @@ -357,13 +357,13 @@ public PreferencesDialog (Cheese.Camera */ private void on_camera_update_num_camera_devices () { - unowned GLib.PtrArray devices = camera.get_camera_devices (); - Cheese.CameraDevice dev; + GLib.GenericArray devices = camera.get_camera_devices (); + unowned Cheese.CameraDevice dev; // Add (if) / Remove (else) a camera device. - if (devices.len > camera_model.iter_n_children (null)) + if (devices.length > camera_model.iter_n_children (null)) { - dev = (Cheese.CameraDevice) devices.index (devices.len - 1); + dev = devices.get (devices.length - 1); add_camera_device(dev); } else @@ -382,12 +382,11 @@ public PreferencesDialog (Cheese.Camera bool device_removed = false; devices.foreach ((device) => { - var old_device = (Cheese.CameraDevice) device; Cheese.CameraDevice new_device; camera_model.get (iter, 1, out new_device, -1); // Found the device that was removed. - if (old_device != new_device) + if (device != new_device) { remove_camera_device (iter, new_device, active_device); device_removed = true; @@ -418,17 +417,16 @@ public PreferencesDialog (Cheese.Camera * * @param device a Cheese.CameraDevice to add to the device combo box model */ - private void add_camera_device (void *device) + private void add_camera_device (Cheese.CameraDevice device) { TreeIter iter; - Cheese.CameraDevice dev = (Cheese.CameraDevice) device; camera_model.append (out iter); camera_model.set (iter, - 0, dev.get_name (), - 1, dev); + 0, device.get_name (), + 1, device); - if (camera.get_selected_device () == dev) + if (camera.get_selected_device () == device) source_combo.set_active_iter (iter); if (camera_model.iter_n_children (null) > 1) @@ -445,12 +443,12 @@ public PreferencesDialog (Cheese.Camera private void remove_camera_device (TreeIter iter, Cheese.CameraDevice device_node, Cheese.CameraDevice active_device_node) { - unowned GLib.PtrArray devices = camera.get_camera_devices (); + GLib.GenericArray devices = camera.get_camera_devices (); // Check if the camera that we want to remove, is the active one if (device_node == active_device_node) { - if (devices.len > 0) + if (devices.length > 0) set_new_available_camera_device (iter); else this.hide (); diff -Naurp cheese-3.38.0.orig/src/cheese-window.vala cheese-3.38.0/src/cheese-window.vala --- cheese-3.38.0.orig/src/cheese-window.vala 2020-09-15 06:22:10.055515300 -0500 +++ cheese-3.38.0/src/cheese-window.vala 2021-04-08 12:49:40.471135295 -0500 @@ -1216,9 +1216,9 @@ public class Cheese.MainWindow : Gtk.App */ public void on_switch_camera_clicked () { - Cheese.CameraDevice selected; - Cheese.CameraDevice next = null; - GLib.PtrArray cameras; + unowned Cheese.CameraDevice selected; + unowned Cheese.CameraDevice next = null; + GLib.GenericArray cameras; uint i; if (camera == null) @@ -1235,9 +1235,9 @@ public class Cheese.MainWindow : Gtk.App cameras = camera.get_camera_devices (); - for (i = 0; i < cameras.len; i++) + for (i = 0; i < cameras.length; i++) { - next = (Cheese.CameraDevice )cameras.index (i); + next = cameras.get (i); if (next == selected) { @@ -1245,13 +1245,13 @@ public class Cheese.MainWindow : Gtk.App } } - if (i + 1 < cameras.len) + if (i + 1 < cameras.length) { - next = (Cheese.CameraDevice )cameras.index (i + 1); + next = cameras.get (i + 1); } else { - next = (Cheese.CameraDevice )cameras.index (0); + next = cameras.get (0); } if (next == selected) @@ -1269,8 +1269,8 @@ public class Cheese.MainWindow : Gtk.App */ public void set_switch_camera_button_state () { - Cheese.CameraDevice selected; - GLib.PtrArray cameras; + unowned Cheese.CameraDevice selected; + GLib.GenericArray cameras; if (camera == null) { @@ -1288,7 +1288,7 @@ public class Cheese.MainWindow : Gtk.App cameras = camera.get_camera_devices (); - if (cameras.len > 1) + if (cameras.length > 1) { switch_camera_button.set_visible (true); return; diff -Naurp cheese-3.38.0.orig/src/vapi/cheese-common.vapi cheese-3.38.0/src/vapi/cheese-common.vapi --- cheese-3.38.0.orig/src/vapi/cheese-common.vapi 2020-09-15 06:22:10.056515200 -0500 +++ cheese-3.38.0/src/vapi/cheese-common.vapi 2021-04-08 12:44:07.748053723 -0500 @@ -35,7 +35,7 @@ namespace Cheese [CCode (has_construct_function = false)] public Camera (Clutter.Actor video_texture, string camera_device_node, int x_resolution, int y_resolution); public bool get_balance_property_range (string property, double min, double max, double def); - public unowned GLib.PtrArray get_camera_devices (); + public GLib.GenericArray get_camera_devices (); public unowned Cheese.VideoFormat get_current_video_format (); public int get_num_camera_devices (); public unowned Cheese.CameraDevice get_selected_device ();