diff options
author | Daniel Boles <dboles.src@gmail.com> | 2019-11-09 19:43:39 +0000 |
---|---|---|
committer | Daniel Boles <dboles@src.gnome.org> | 2019-11-09 20:01:56 +0000 |
commit | cecbf3c66aa016033207668179a83b3138c8ad0d (patch) | |
tree | 4dc5c68f43dea2c9a12728ddd727f4b9f170af1f /glib/src/binding.hg | |
parent | 4ed3ff9cad836dc7b24282a112d66847292a9baa (diff) | |
download | glibmm-cecbf3c66aa016033207668179a83b3138c8ad0d.tar.gz |
Binding: no point to set target value if got false
If we return false, GBinding ignores target GValue, so there’s no point
setting it. Besides, if the transform function returned false, that says
they couldn't calculate a target value, so they shouldn’t assign to `to`
I default-construct primitive `T_to`s in case anyone *was* reading those
for some daft reason, so they get a zero-initialised value instead of UB
Diffstat (limited to 'glib/src/binding.hg')
-rw-r--r-- | glib/src/binding.hg | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/glib/src/binding.hg b/glib/src/binding.hg index 840b0b62..7431a374 100644 --- a/glib/src/binding.hg +++ b/glib/src/binding.hg @@ -413,14 +413,16 @@ private: { Glib::Value<T_from> from_glib_value; from_glib_value.init(from_value); + T_to to{}; + + if (!typed_transform(from_glib_value.get(), to)) + return false; + 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); to_glib_value.set(to); g_value_copy(to_glib_value.gobj(), to_value); - return result; + return true; } private: |