mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
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. Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/893#note_1766079
This commit is contained in:
parent
ad07e9043f
commit
a6d40b610b
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user