[Spice-commits] 2 commits - src/spice-grabsequence.c src/spice-session.c src/spice-widget.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 28 13:28:18 UTC 2021


 src/spice-grabsequence.c |    6 +++---
 src/spice-session.c      |    6 +++---
 src/spice-widget.c       |    8 +++++---
 3 files changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 61002aaa3bbbacbe47d3a52f5be0d8eab06912c6
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Jun 28 12:23:38 2021 +0400

    Remove incorrect volatile usage
    
    See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/src/spice-grabsequence.c b/src/spice-grabsequence.c
index 50e774d..dd454c9 100644
--- a/src/spice-grabsequence.c
+++ b/src/spice-grabsequence.c
@@ -29,14 +29,14 @@
 GType spice_grab_sequence_get_type(void)
 {
 	static GType grab_sequence_type = 0;
-	static volatile gsize grab_sequence_type_volatile;
+	static gsize grab_sequence_type_once;
 
-	if (g_once_init_enter(&grab_sequence_type_volatile)) {
+	if (g_once_init_enter(&grab_sequence_type_once)) {
 		grab_sequence_type = g_boxed_type_register_static
 			("SpiceGrabSequence",
 			 (GBoxedCopyFunc)spice_grab_sequence_copy,
 			 (GBoxedFreeFunc)spice_grab_sequence_free);
-		g_once_init_leave(&grab_sequence_type_volatile,
+		g_once_init_leave(&grab_sequence_type_once,
 				  grab_sequence_type);
 	}
 
diff --git a/src/spice-session.c b/src/spice-session.c
index d6ec344..bb3c6cd 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -239,11 +239,11 @@ GType
 spice_image_compress_get_type (void)
 {
   static GType type = 0;
-  static volatile gsize type_volatile = 0;
+  static gsize type_once = 0;
 
-  if (g_once_init_enter(&type_volatile)) {
+  if (g_once_init_enter(&type_once)) {
     type = g_enum_register_static ("SpiceImageCompress", _spice_image_compress_values);
-    g_once_init_leave(&type_volatile, type);
+    g_once_init_leave(&type_once, type);
   }
 
   return type;
commit edba707b32d47977e14f576854f61a0c1a569eab
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Jun 28 12:12:21 2021 +0400

    Fix potential div0 crash
    
    gdk_monitor_get_geometry() may return 0-size, and leads to crash:
    https://bugzilla.redhat.com/show_bug.cgi?id=1941627
    
    Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 7ee02a8..afcf45a 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1379,9 +1379,11 @@ static void recalc_geometry(GtkWidget *widget)
         width_mm = gdk_monitor_get_width_mm(monitor);
         gdk_monitor_get_geometry(monitor, &geometry);
         /* FIXME: gives wrong results atm: https://gitlab.gnome.org/GNOME/gtk/-/issues/3066 */
-        width_mm = (width_mm * d->ww / geometry.width) / zoom * scale_factor;
-        height_mm = (height_mm * d->wh / geometry.height) / zoom * scale_factor;
-        has_display_mm = true;
+        if (geometry.width > 0 && geometry.height > 0) {
+            width_mm = (width_mm * d->ww / geometry.width) / zoom * scale_factor;
+            height_mm = (height_mm * d->wh / geometry.height) / zoom * scale_factor;
+            has_display_mm = true;
+        }
     }
 
     DISPLAY_DEBUG(display,


More information about the Spice-commits mailing list