[glibmm/wip/dboles/Binding-2.62: 4/4] Binding: no point to set target value if got false
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/wip/dboles/Binding-2.62: 4/4] Binding: no point to set target value if got false
- Date: Sat, 9 Nov 2019 16:04:44 +0000 (UTC)
commit 82d9568961cd3677ffdda6706d060298cd5b7ff9
Author: Daniel Boles <dboles src gmail com>
Date: Sat Nov 9 15:19:55 2019 +0000
Binding: no point to set target value if got false
If we return false, GBinding will not use the destination GValue, so
there is no point in setting it. Besides, if the user supplying the
transform function returned false, they probably couldn't determine a
new value to set by reference anyway, so we'd just reapply the same one.
By not doing this, we avoid some pointless work just wasting cycles.
glib/src/binding.hg | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/glib/src/binding.hg b/glib/src/binding.hg
index 221554aa..17275cd8 100644
--- a/glib/src/binding.hg
+++ b/glib/src/binding.hg
@@ -419,7 +419,10 @@ private:
T_to to = to_glib_value.get();
const bool result = typed_transform(from_glib_value.get(), to);
- to_glib_value.set(to);
+
+ if (result)
+ to_glib_value.set(to);
+
g_value_copy(to_glib_value.gobj(), to_value);
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]