]> sigrok.org Git - libsigrok.git/commitdiff
bindings: Session::set_trigger(): Fix segfault condition.
authorUwe Hermann <redacted>
Mon, 24 Nov 2014 00:11:17 +0000 (01:11 +0100)
committerUwe Hermann <redacted>
Mon, 24 Nov 2014 00:11:17 +0000 (01:11 +0100)
sr_session_trigger_set(sess, NULL) is a valid thing to do, meaning that
any trigger shall be removed from the session.

This closes bugs #491 and #496.

bindings/cxx/classes.cpp

index da21086c50510199456e8b0a18c2a85815be825c..efb4995db6152f705053f041830daae6c04fbdd6 100644 (file)
@@ -1138,7 +1138,11 @@ shared_ptr<Trigger> Session::trigger()
 
 void Session::set_trigger(shared_ptr<Trigger> trigger)
 {
-       check(sr_session_trigger_set(_structure, trigger->_structure));
+       if (!trigger)
+               // Set NULL trigger, i.e. remove any trigger from the session.
+               check(sr_session_trigger_set(_structure, NULL));
+       else
+               check(sr_session_trigger_set(_structure, trigger->_structure));
        _trigger = trigger;
 }