[glibmm/wip/dboles/Binding-2.62] Binding: no point to set target value if got false



commit 2a92d2cc94bfd3fb9045840b3913a854f310d673
Author: Daniel Boles <dboles src gmail com>
Date:   Sat Nov 9 16:17:40 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 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/glib/src/binding.hg b/glib/src/binding.hg
index 221554aa..c36bccaa 100644
--- a/glib/src/binding.hg
+++ b/glib/src/binding.hg
@@ -414,14 +414,18 @@ private:
     {
       Glib::Value<T_from> from_glib_value;
       from_glib_value.init(from_value);
+
       Glib::Value<T_to> to_glib_value;
       to_glib_value.init(to_value);
+
       T_to to = to_glib_value.get();
 
-      const bool result = typed_transform(from_glib_value.get(), to);
+      if (!typed_transform(from_glib_value.get(), to))
+        return false;
+
       to_glib_value.set(to);
       g_value_copy(to_glib_value.gobj(), to_value);
-      return result;
+      return true;
     }
 
   private:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]