Page MenuHome

"Fix" for T39039
ActivePublic

Authored by Bastien Montagne (mont29) on Mar 8 2014, 4:38 PM.
Tags
None
Tokens
"Like" token, awarded by mattali.
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 2cb28eb..c6a484a 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2871,7 +2871,8 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
ScrArea *sa = CTX_wm_area(C);
ARegion *arn;
- /* keep current region */
+ /* keep last region (the "camera" view, also the one we do not alter when switching *to* quadview"). */
+ ar = sa->regionbase.last;
ar->alignment = 0;
if (sa->spacetype == SPACE_VIEW3D) {
@@ -2909,7 +2910,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
/* lock views and set them */
if (sa->spacetype == SPACE_VIEW3D) {
- View3D *v3d = sa->spacedata.first;
+ //View3D *v3d = sa->spacedata.first;
int index_qsplit = 0;
/* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set,
@@ -2925,8 +2926,8 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
region_quadview_init_rv3d(sa, ar, viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
- if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
- else region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_PERSPORTHO, RV3D_PERSP);
+ //if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA, RV3D_CAMOB);
+ //else region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_PERSPORTHO, RV3D_PERSP);
}
ED_area_tag_redraw(sa);

Event Timeline

Bastien Montagne (mont29) changed the title of this paste from untitled to "Fix" for T39039.
Bastien Montagne (mont29) updated the paste's language from autodetect to autodetect.

*Edited* - setting: ar = sa->regionbase.last; crashes for me in region_quadview_exec

The crash is caused by CTX_wm_region being left with a freed ar pointer. easy enough to solve.

Attached an alternate fix, which should help with other areas too.

This makes it so the unlocked (user) view is selected first.

I don't especially like adding this extra complexity into BKE_area_find_region_type but it has the advantage that other operators will find the user view first.

We could also check on making it so the user view is inserted and found first.

		ARegion *BKE_area_find_region_type(ScrArea *sa, int type)
		{
			ARegion *ar = NULL;
		
			if (sa) {
				for (ar = sa->regionbase.first; ar; ar = ar->next) {
					if (ar->regiontype == type) {
						break;
					}
				}
			}
		
			if (sa->spacetype == SPACE_VIEW3D) {
				if (ar && (type == RGN_TYPE_WINDOW) && (ar->alignment == RGN_ALIGN_QSPLIT)) {
					ARegion *ar_fallback = ar;
					ar = ar->next;
					while (ar) {
						if (ar->regiontype == type) {
							RegionView3D *rv3d = ar->regiondata;
							if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
								break;
							}
						}
						ar = ar->next;
					}
					if (ar == NULL) {
						ar = ar_fallback;
					}
				}
			}
		
			return ar;
		}