aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-02 00:49:33 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-02 00:49:36 +0200
commite4558e9ba0e78744c91d9efe356417c63da0095f (patch)
tree90499627fdd15f2297aca610341742b8b08c8432 /src
parent270c6101f6236c8f949253e0f373c97d99b4ba63 (diff)
downloadjancity-e4558e9ba0e78744c91d9efe356417c63da0095f.tar.gz
gui.c: fix wrong logic on gui_coords
The older logic would iterate for all parents, where each parent would again iterate for all of its parents, until no more parents found. This is however not needed, since only inspecting the closest parent will already cause the (recursive) algorithm to iterate for all parents.
Diffstat (limited to 'src')
-rw-r--r--src/gui/src/gui.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gui/src/gui.c b/src/gui/src/gui.c
index 99701f1..329bc2d 100644
--- a/src/gui/src/gui.c
+++ b/src/gui/src/gui.c
@@ -34,7 +34,9 @@ void gui_coords(const struct gui_common *const g, short *const x,
*x = g->x;
*y = g->y;
- for (const struct gui_common *p = g->parent; p; p = p->parent)
+ const struct gui_common *p = g->parent;
+
+ if (p)
{
short px = p->x, py = p->y;