bindings: Session::set_trigger(): Fix segfault condition.

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.
This commit is contained in:
Uwe Hermann 2014-11-24 01:11:17 +01:00
parent 9f42e2e6be
commit e835e8080b
1 changed files with 5 additions and 1 deletions

View 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;
}