Instead of crashing, an error message is displayed if a function of the gpu module is called without a GPU context.
Brecht Van Lommel (brecht) Campbell Barton (campbellbarton) Jacques Lucke (JacquesLucke) Bastien Montagne (mont29)
- rBS945007b32e9a: Fix T59773: Raise exception if the gpu module is used in backgound mode.
rB945007b32e9a: Fix T59773: Raise exception if the gpu module is used in backgound mode.
This is too vague. Could be something more specific like:
GPU functions for drawing are not available in background mode.
This seems to permanently disable the GPU module when Python tries to import it. But it can be initialized later on still, so this seems wrong.
Maybe it is better to disallow important the module at the top level. @Bastien Montagne (mont29) say in the task it wasn't necessary, but to me that seems like the cleaner solution?
I agree, I didn't think of this. With a small change in the C code the python files can be initialized before the GPU.
- Check if gpu is initialized before calls instead of when initializing module.
I have added check only on functions that initialize types and on the one that gets builtin shaders. Since these should always be called first and that the code in python should be stopped after an error.