47 lines
1.7 KiB
Diff
47 lines
1.7 KiB
Diff
From: Daniel Boles <dboles.src@gmail.com>
|
|
Date: Sun, 11 Jun 2023 11:37:45 +0100
|
|
Subject: Popover: Clarify/guard out rect of get_pointing_to
|
|
|
|
Clarify that we zero out the widget coords and only keep its dimensions.
|
|
|
|
If we have no widget to fall-back to, memset to 0 the output @rect since
|
|
we return FALSE whether or not we have widget, so protect users from not
|
|
knowing if there was a widget and possibly accessing uninitialised ints.
|
|
|
|
Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/893#note_1766079
|
|
Origin: 3.24.39, commit:a6d40b610be6acb635d8732c11bb6d866bf2e95d
|
|
---
|
|
gtk/gtkpopover.c | 5 ++++-
|
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
|
|
index 82ad2fc..b812e0e 100644
|
|
--- a/gtk/gtkpopover.c
|
|
+++ b/gtk/gtkpopover.c
|
|
@@ -112,6 +112,7 @@
|
|
#include "gtkstylecontextprivate.h"
|
|
#include "gtkprogresstrackerprivate.h"
|
|
#include "gtksettingsprivate.h"
|
|
+#include <string.h> /* memset */
|
|
|
|
#ifdef GDK_WINDOWING_WAYLAND
|
|
#include "wayland/gdkwayland.h"
|
|
@@ -2316,7 +2317,7 @@ gtk_popover_set_pointing_to (GtkPopover *popover,
|
|
* If a rectangle to point to has been set, this function will
|
|
* return %TRUE and fill in @rect with such rectangle, otherwise
|
|
* it will return %FALSE and fill in @rect with the attached
|
|
- * widget coordinates.
|
|
+ * widget width and height if a widget exists, otherwise it will zero-out @rect.
|
|
*
|
|
* Returns: %TRUE if a rectangle to point to was set.
|
|
**/
|
|
@@ -2336,6 +2337,8 @@ gtk_popover_get_pointing_to (GtkPopover *popover,
|
|
gtk_widget_get_allocation (priv->widget, rect);
|
|
rect->x = rect->y = 0;
|
|
}
|
|
+ else
|
|
+ memset (rect, 0, sizeof (GdkRectangle));
|
|
|
|
return priv->has_pointing_to;
|
|
}
|