No matter what I type into the console, or execute from the text buffer, blender shows an error but continues on as usual. However, I recently noticed that many exceptions (involving bgl callbacks) make blender crash if they happen inside the modal operator.

Why is that?

  • $\begingroup$ care to elaborate on the code in the modal function? bgl callbacks? $\endgroup$ – zeffii Apr 26 '15 at 7:41

bgl callbacks

The modal part of your operator needs to return something each time it's called, in the case of an exception that is probably return {'CANCELLED'}. Most exceptions are not fatal, but exceptions in bgl callbacks can be.

One crash is one too many, you might have to stick in a try/except (with traceback), at least until you find the cause of the exception in the bgl callback and find a way to prevent it, you also need to correct the GL state before the callback function ends. Else expect undefined behaviour.

  • 1
    $\begingroup$ Yes, bgl callbacks indeed, but I was more curious as to why it isn't "safety-wrapped" like the other execution contexts, than looking for a solution. I did co with try/except blocks, no worries. $\endgroup$ – Ludwik Apr 26 '15 at 7:41
  • 1
    $\begingroup$ modal bgl is one of the few scenarios where i've seen pretty gruesome 'close to desktop' style crashing. Solved by correcting the logic in the bgl callback.. I think you are right to ask why that should be any different, it perhaps deserves a dedicated question, or rename your question to include the term involving exceptions in bgl callbacks $\endgroup$ – zeffii Apr 26 '15 at 7:49
  • $\begingroup$ I might do that later today $\endgroup$ – Ludwik Apr 26 '15 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.