[retro-gtk/emit-iterated-cleanup: 6/6] core: Auto emit 'iterated' on cleanup
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/emit-iterated-cleanup: 6/6] core: Auto emit 'iterated' on cleanup
- Date: Tue, 4 Feb 2020 20:50:42 +0000 (UTC)
commit 39141cf1d7e4a74f31f80db45abcc3e0678ec089
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Jan 30 20:31:04 2020 +0100
core: Auto emit 'iterated' on cleanup
Automatically emit the 'iterated' signal at the end of
retro_core_iteration() thanks to a cleanup attribute. This makes the
code simpler and safer by ensuring we emit it when needed and no more.
retro-gtk/retro-core.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index 8e334c1..3159266 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -1648,6 +1648,13 @@ retro_core_reset (RetroCore *self)
retro_core_pop_cb_data ();
}
+static inline void
+emit_iterated (RetroCore **self)
+{
+ if (*self)
+ g_signal_emit (*self, signals[SIG_ITERATED_SIGNAL], 0);
+}
+
/**
* retro_core_iteration:
* @self: a #RetroCore
@@ -1665,6 +1672,7 @@ retro_core_iteration (RetroCore *self)
gsize size;
gsize new_size;
gboolean success;
+ RetroCore *iterated __attribute__((cleanup(emit_iterated))) = RETRO_CORE (self);
g_return_if_fail (RETRO_IS_CORE (self));
@@ -1676,8 +1684,6 @@ retro_core_iteration (RetroCore *self)
run ();
retro_core_pop_cb_data ();
- g_signal_emit (self, signals[SIG_ITERATED_SIGNAL], 0);
-
return;
}
@@ -1695,8 +1701,6 @@ retro_core_iteration (RetroCore *self)
g_critical ("Couldn't run ahead: serialization not supported.");
- g_signal_emit (self, signals[SIG_ITERATED_SIGNAL], 0);
-
return;
}
@@ -1715,8 +1719,6 @@ retro_core_iteration (RetroCore *self)
G_GSIZE_FORMAT", expected %"G_GSIZE_FORMAT" or less.",
new_size, size);
- g_signal_emit (self, signals[SIG_ITERATED_SIGNAL], 0);
-
return;
}
@@ -1733,8 +1735,6 @@ retro_core_iteration (RetroCore *self)
g_free (data);
- g_signal_emit (self, signals[SIG_ITERATED_SIGNAL], 0);
-
return;
}
@@ -1752,8 +1752,6 @@ retro_core_iteration (RetroCore *self)
g_free (data);
- g_signal_emit (self, signals[SIG_ITERATED_SIGNAL], 0);
-
return;
}
@@ -1767,14 +1765,10 @@ retro_core_iteration (RetroCore *self)
g_free (data);
- g_signal_emit (self, signals[SIG_ITERATED_SIGNAL], 0);
-
return;
}
g_free (data);
-
- g_signal_emit (self, signals[SIG_ITERATED_SIGNAL], 0);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]