[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34848] trunk/blender/source/blender: Bug fix #26021

Ton Roosendaal ton at blender.org
Mon Feb 14 18:09:03 CET 2011


Revision: 34848
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34848
Author:   ton
Date:     2011-02-14 17:09:02 +0000 (Mon, 14 Feb 2011)
Log Message:
-----------
Bug fix #26021

Very nasty UI code issue: since every button is re-defined on a
redraw, having UI redraws while using a button was not possible.

This was solved long ago by copying over data from previous button.

However, this fails when buttons have callbacks with its own (or
a parent button) pointer. 

This bug reporter found crashes in draw-overlap UI mode, this 
draws entire UI over for every menu redraws, making previous button
pointers invalid. (for triple buffer, the UI is not redrawn, only
the menus).

In general: all systems falling back to old swapbuffers would have
suffered some instability because of this.

Fix is that now the old button gets lifted out from the previous
list and inserted in the new list. Works fine, but needs some tests!

Also in this commit: TIFF endian switching not needed for 16 bits tiff.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/imbuf/intern/tiff.c

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2011-02-14 16:54:52 UTC (rev 34847)
+++ trunk/blender/source/blender/editors/interface/interface.c	2011-02-14 17:09:02 UTC (rev 34848)
@@ -501,10 +501,10 @@
 	return 1;
 }
 
-static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut *but)
+static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut **butpp)
 {
 	uiBlock *oldblock;
-	uiBut *oldbut;
+	uiBut *oldbut, *but= *butpp;
 	int found= 0;
 
 	oldblock= block->oldblock;
@@ -515,35 +515,51 @@
 		if(ui_but_equals_old(oldbut, but)) {
 			if(oldbut->active) {
 #if 0
-				but->flag= oldbut->flag;
+//				but->flag= oldbut->flag;
 #else
 				/* exception! redalert flag can't be update from old button. 
 				 * perhaps it should only copy spesific flags rather then all. */
-				but->flag= (oldbut->flag & ~UI_BUT_REDALERT) | (but->flag & UI_BUT_REDALERT);
+//				but->flag= (oldbut->flag & ~UI_BUT_REDALERT) | (but->flag & UI_BUT_REDALERT);
 #endif
-				but->active= oldbut->active;
-				but->pos= oldbut->pos;
-				but->ofs= oldbut->ofs;
-				but->editstr= oldbut->editstr;
-				but->editval= oldbut->editval;
-				but->editvec= oldbut->editvec;
-				but->editcoba= oldbut->editcoba;
-				but->editcumap= oldbut->editcumap;
-				but->selsta= oldbut->selsta;
-				but->selend= oldbut->selend;
-				but->softmin= oldbut->softmin;
-				but->softmax= oldbut->softmax;
-				but->linkto[0]= oldbut->linkto[0];
-				but->linkto[1]= oldbut->linkto[1];
+//				but->active= oldbut->active;
+//				but->pos= oldbut->pos;
+//				but->ofs= oldbut->ofs;
+//				but->editstr= oldbut->editstr;
+//				but->editval= oldbut->editval;
+//				but->editvec= oldbut->editvec;
+//				but->editcoba= oldbut->editcoba;
+//				but->editcumap= oldbut->editcumap;
+//				but->selsta= oldbut->selsta;
+//				but->selend= oldbut->selend;
+//				but->softmin= oldbut->softmin;
+//				but->softmax= oldbut->softmax;
+//				but->linkto[0]= oldbut->linkto[0];
+//				but->linkto[1]= oldbut->linkto[1];
 				found= 1;
-
-				oldbut->active= NULL;
+//				oldbut->active= NULL;
+			
+				/* move button over from oldblock to new block */
+				BLI_remlink(&oldblock->buttons, oldbut);
+				BLI_insertlink(&block->buttons, but, oldbut);
+				oldbut->block= block;
+				*butpp= oldbut;
+				
+				/* still stuff needs to be copied */
+				oldbut->x1= but->x1; oldbut->y1= but->y1;
+				oldbut->x2= but->x2; oldbut->y2= but->y2;
+				oldbut->context= but->context; /* set by Layout */
+				
+				BLI_remlink(&block->buttons, but);
+				ui_free_but(C, but);
+				
+				/* note: if layout hasn't been applied yet, it uses old button pointers... */
 			}
-
-			/* ensures one button can get activated, and in case the buttons
-			 * draw are the same this gives O(1) lookup for each button */
-			BLI_remlink(&oldblock->buttons, oldbut);
-			ui_free_but(C, oldbut);
+			else {
+				/* ensures one button can get activated, and in case the buttons
+				 * draw are the same this gives O(1) lookup for each button */
+				BLI_remlink(&oldblock->buttons, oldbut);
+				ui_free_but(C, oldbut);
+			}
 			
 			break;
 		}
@@ -695,7 +711,7 @@
 	 * blocking, while still alowing buttons to be remade each redraw as it
 	 * is expected by blender code */
 	for(but=block->buttons.first; but; but=but->next) {
-		if(ui_but_update_from_old_block(C, block, but))
+		if(ui_but_update_from_old_block(C, block, &but))
 			ui_check_but(but);
 		
 		/* temp? Proper check for greying out */
@@ -912,7 +928,7 @@
 }
 
 /* XXX 2.50 no links supported yet */
-
+#if 0
 static int uibut_contains_pt(uiBut *UNUSED(but), short *UNUSED(mval))
 {
 	return 0;
@@ -943,8 +959,8 @@
 
 	return NULL;
 }
+#endif
 
-
 static uiBut *ui_find_inlink(uiBlock *block, void *poin)
 {
 	uiBut *but;

Modified: trunk/blender/source/blender/imbuf/intern/tiff.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/tiff.c	2011-02-14 16:54:52 UTC (rev 34847)
+++ trunk/blender/source/blender/imbuf/intern/tiff.c	2011-02-14 17:09:02 UTC (rev 34848)
@@ -435,9 +435,11 @@
 
 	if(success) {
 		ibuf->profile = (bitspersample==32)?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB;
-			
-		if(ENDIAN_ORDER == B_ENDIAN)
-			IMB_convert_rgba_to_abgr(tmpibuf);
+
+//		Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton)
+		if(bitspersample < 16)
+			if(ENDIAN_ORDER == B_ENDIAN)
+				IMB_convert_rgba_to_abgr(tmpibuf);
 		if(premul) {
 			IMB_premultiply_alpha(tmpibuf);
 			ibuf->flags |= IB_premul;




More information about the Bf-blender-cvs mailing list