Fix T55452: Crash on saving with visible particle system.

Missing Main pointer in recent refactor/cleanup of G.main usages...
This commit is contained in:
Bastien Montagne 2018-06-12 16:17:05 +02:00
parent a6585fa4b1
commit ec4ce908db
Notes: blender-bot 2023-02-14 05:44:19 +01:00
Referenced by issue #55481, Crash with particle system when Object/Group selected
Referenced by issue #55452, Crash on saving with visible particle system
4 changed files with 16 additions and 12 deletions

View File

@ -362,7 +362,7 @@ void ED_view3d_mats_rv3d_restore(struct RegionView3D *rv3d, s
bool ED_view3d_context_activate(struct bContext *C);
void ED_view3d_draw_offscreen_init(struct Main *bmain, struct Scene *scene, struct View3D *v3d);
void ED_view3d_draw_offscreen(
struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
struct Main *bmain, struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
struct GPUFX *fx, struct GPUFXSettings *fx_settings,
struct GPUOffScreen *ofs);

View File

@ -2672,7 +2672,7 @@ static void gpu_update_lamps_shadows_world(Main *bmain, Scene *scene, View3D *v3
/* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */
ED_view3d_draw_offscreen(
scene, v3d, &ar, winsize, winsize, viewmat, winmat,
bmain, scene, v3d, &ar, winsize, winsize, viewmat, winmat,
false, false, true,
NULL, NULL, NULL, NULL);
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
@ -2827,11 +2827,14 @@ void ED_view3d_update_viewmat(
*/
static void view3d_draw_objects(
const bContext *C,
Main *bmain,
Scene *scene, View3D *v3d, ARegion *ar,
const char **grid_unit,
const bool do_bgpic, const bool draw_offscreen, GPUFX *fx)
{
Main *bmain = CTX_data_main(C);
if (bmain == NULL) {
bmain = CTX_data_main(C);
}
RegionView3D *rv3d = ar->regiondata;
Base *base;
const bool do_camera_frame = !draw_offscreen;
@ -3168,7 +3171,7 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar)
* stuff like shadow buffers
*/
void ED_view3d_draw_offscreen(
Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy,
Main *bmain, Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy,
float viewmat[4][4], float winmat[4][4],
bool do_bgpic, bool do_sky, bool is_persp, const char *viewname,
GPUFX *fx, GPUFXSettings *fx_settings,
@ -3237,7 +3240,7 @@ void ED_view3d_draw_offscreen(
}
/* main drawing call */
view3d_draw_objects(NULL, scene, v3d, ar, NULL, do_bgpic, true, do_compositing ? fx : NULL);
view3d_draw_objects(NULL, bmain, scene, v3d, ar, NULL, do_bgpic, true, do_compositing ? fx : NULL);
/* post process */
if (do_compositing) {
@ -3371,7 +3374,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
if ((samples && use_full_sample) == 0) {
/* Single-pass render, common case */
ED_view3d_draw_offscreen(
scene, v3d, ar, sizex, sizey, NULL, winmat,
bmain, scene, v3d, ar, sizex, sizey, NULL, winmat,
draw_background, draw_sky, !is_ortho, viewname,
fx, &fx_settings, ofs);
@ -3397,7 +3400,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
/* first sample buffer, also initializes 'rv3d->persmat' */
ED_view3d_draw_offscreen(
scene, v3d, ar, sizex, sizey, NULL, winmat,
bmain, scene, v3d, ar, sizex, sizey, NULL, winmat,
draw_background, draw_sky, !is_ortho, viewname,
fx, &fx_settings, ofs);
GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@ -3416,7 +3419,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
(jit_ofs[j][1] * 2.0f) / sizey);
ED_view3d_draw_offscreen(
scene, v3d, ar, sizex, sizey, NULL, winmat_jitter,
bmain, scene, v3d, ar, sizex, sizey, NULL, winmat_jitter,
draw_background, draw_sky, !is_ortho, viewname,
fx, &fx_settings, ofs);
GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, rect_temp);
@ -3918,7 +3921,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie
}
/* main drawing call */
view3d_draw_objects(C, scene, v3d, ar, grid_unit, true, false, do_compositing ? rv3d->compositor : NULL);
view3d_draw_objects(C, bmain, scene, v3d, ar, grid_unit, true, false, do_compositing ? rv3d->compositor : NULL);
/* post process */
if (do_compositing) {

View File

@ -169,6 +169,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a
MatrixObject *py_mat_modelview, *py_mat_projection;
PyObject *py_scene, *py_region, *py_view3d;
struct Main *bmain = G.main; /* XXX UGLY! */
Scene *scene;
View3D *v3d;
ARegion *ar;
@ -194,14 +195,14 @@ static PyObject *pygpu_offscreen_draw_view3d(BPy_GPUOffScreen *self, PyObject *a
fx_settings = v3d->fx_settings; /* full copy */
ED_view3d_draw_offscreen_init(G.main, scene, v3d);
ED_view3d_draw_offscreen_init(bmain, scene, v3d);
rv3d_mats = ED_view3d_mats_rv3d_backup(ar->regiondata);
GPU_offscreen_bind(self->ofs, true); /* bind */
ED_view3d_draw_offscreen(
scene, v3d, ar, GPU_offscreen_width(self->ofs), GPU_offscreen_height(self->ofs),
bmain, scene, v3d, ar, GPU_offscreen_width(self->ofs), GPU_offscreen_height(self->ofs),
(float(*)[4])py_mat_modelview->matrix, (float(*)[4])py_mat_projection->matrix,
false, true, true, "",
fx, &fx_settings,

View File

@ -1146,7 +1146,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
/* blend file thumbnail */
/* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
/* Main now can store a .blend thumbnail, usefull for background mode or thumbnail customization. */
main_thumb = thumb = CTX_data_main(C)->blen_thumb;
main_thumb = thumb = bmain->blen_thumb;
if ((U.flag & USER_SAVE_PREVIEWS) && BLI_thread_is_main()) {
ibuf_thumb = blend_file_thumb(bmain, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
}