Solved sporadic crash when setmode is called multiple times #76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had the problem, that sometimes if I wanted to set an output the software crashed with the exception "Channel 26 is invalid".
I tracked down the problem to the is_in() function in PythonFunctions.h. The moment the exception is thrown, the is_in() functions received an empty dictionary. I tested this by printing the size of the dictionary in the is_in() function.
I'm not sure why this happens. Because the _channel_data dictionary is only updated on startup and on every setmode(), I added a check to change the dictionary only once. This should not be a problem in my opinion, as you cannot update the mode once it has been set.
After the change, the problem no longer occurred. However, since it occurred only sporadically, I cannot say with 100% certainty that it is solved.