Instead of crashing, an error message is displayed if a function of the gpu module is called without a GPU context.
Details
Details
- Reviewers
Brecht Van Lommel (brecht) Campbell Barton (campbellbarton) Jacques Lucke (JacquesLucke) Bastien Montagne (mont29) - Commits
- 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.
Diff Detail
Diff Detail
- Repository
- rB Blender
- Branch
- blender2.8_fix_T59773 (branched from blender2.8)
- Build Status
Buildable 2688 Build 2688: arc lint + arc unit
Event Timeline
| source/blender/python/gpu/gpu_py.c | ||
|---|---|---|
| 56 | This is too vague. Could be something more specific like: GPU functions for drawing are not available in background mode. | |
| 63 | 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? | |
| source/blender/python/gpu/gpu_py.c | ||
|---|---|---|
| 63 | 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. | |
Comment Actions
- 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.