[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21679] branches/blender2.5/blender/source /blender: fixes for errors on startup and compiler errors and draw speedup.

Campbell Barton ideasman42 at gmail.com
Sat Jul 18 18:27:25 CEST 2009


Revision: 21679
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21679
Author:   campbellbarton
Date:     2009-07-18 18:27:25 +0200 (Sat, 18 Jul 2009)

Log Message:
-----------
fixes for errors on startup and compiler errors and draw speedup.

* Drawing the console text now skips all lines outside the view bounds.

* Added dummy C operators for console.exec and console.autocomplete so blender wont complain at startup, its not really a problem but people testing reported it a few times. Eventually we should have some way python operators are initialized before the spaces operators are checked.

* reordered the imports so the "ui" dir is imported before "io", for now this means bpy.ops is defined before exporters and importers need to use it, was causing a python error on startup.

* fixed all compiler warnings for the console (gcc4.4)

* stopped operators were printing out the return flag.

* removed references to ACT_OT_test, TEXT_OT_console_exec and TEXT_OT_console_autocomplete

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
    branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c
    branches/blender2.5/blender/source/blender/editors/space_console/console_intern.h
    branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c
    branches/blender2.5/blender/source/blender/editors/space_console/space_console.c
    branches/blender2.5/blender/source/blender/editors/space_text/space_text.c
    branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c
    branches/blender2.5/blender/source/blender/python/intern/bpy_operator_wrap.c

Modified: branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2009-07-18 15:14:59 UTC (rev 21678)
+++ branches/blender2.5/blender/source/blender/editors/space_action/action_ops.c	2009-07-18 16:27:25 UTC (rev 21679)
@@ -156,7 +156,7 @@
 	transform_keymap_for_space(wm, keymap, SPACE_ACTION);
 	
 		/* test */
-	WM_keymap_add_item(keymap, "ACT_OT_test", QKEY, KM_PRESS, 0, 0);
+	/* WM_keymap_add_item(keymap, "ACT_OT_test", QKEY, KM_PRESS, 0, 0); */
 }
 
 /* --------------- */

Modified: branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c	2009-07-18 15:14:59 UTC (rev 21678)
+++ branches/blender2.5/blender/source/blender/editors/space_console/console_draw.c	2009-07-18 16:27:25 UTC (rev 21679)
@@ -109,23 +109,28 @@
 static int console_draw_string(	char *str, int str_len,
 									int console_width, int lheight,
 									unsigned char *fg, unsigned char *bg,
-									int winx, int winy,
+									int winx,
+									int ymin, int ymax,
 									int *x, int *y, int draw)
 {	
 	int rct_ofs= lheight/4;
-	int tot_lines = (str_len/console_width)+1;							/* total number of lines for wrapping */
+	int tot_lines = (str_len/console_width)+1; /* total number of lines for wrapping */
+	int y_next = (str_len > console_width) ? (*y)+lheight*tot_lines : (*y)+lheight;
 
 	/* just advance the height */
 	if(draw==0) {
-		if(str_len > console_width)	(*y) += tot_lines * lheight;
-		else						(*y) += lheight;
-
+		*y= y_next;
 		return 1;
 	}
+	else if (y_next-lheight < ymin) {
+		/* have not reached the drawable area so don't break */
+		*y= y_next;
+		return 1;
+	}
 
 	if(str_len > console_width) { /* wrap? */
 		char *line_stride= str + ((tot_lines-1) * console_width);	/* advance to the last line and draw it first */
-		char eol;															/* baclup the end of wrapping */
+		char eol;													/* baclup the end of wrapping */
 		
 		if(bg) {
 			glColor3ub(bg[0], bg[1], bg[2]);
@@ -149,7 +154,7 @@
 			line_stride[console_width] = eol; /* restore */
 			
 			/* check if were out of view bounds */
-			if(*y > winy)
+			if(*y > ymax)
 				return 0;
 		}
 	}
@@ -165,7 +170,7 @@
 		BLF_position(*x, *y, 0); (*y) += lheight;
 		BLF_draw(str);
 		
-		if(*y > winy)
+		if(*y > ymax)
 			return 0;
 	}
 
@@ -230,7 +235,8 @@
 			if(!console_draw_string(	cl->line, cl->len,
 										console_width, sc->lheight,
 										fg, NULL,
-										ar->winx-CONSOLE_DRAW_MARGIN, v2d->cur.ymax,
+										ar->winx-CONSOLE_DRAW_MARGIN,
+										v2d->cur.ymin, v2d->cur.ymax,
 										&x, &y, draw))
 			{
 				/* when drawing, if we pass v2d->cur.ymax, then quit */
@@ -268,7 +274,8 @@
 				if(!console_draw_string(	report->message, report->len,
 											console_width, sc->lheight,
 											fg, bool?bg:NULL,
-											ar->winx-CONSOLE_DRAW_MARGIN, v2d->cur.ymax,
+											ar->winx-CONSOLE_DRAW_MARGIN,
+											v2d->cur.ymin, v2d->cur.ymax,
 											&x, &y, draw))
 				{
 					/* when drawing, if we pass v2d->cur.ymax, then quit */
@@ -279,7 +286,6 @@
 
 				bool = !(bool);
 			}
-			
 		}
 	}
 	y += sc->lheight*2;

Modified: branches/blender2.5/blender/source/blender/editors/space_console/console_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_console/console_intern.h	2009-07-18 15:14:59 UTC (rev 21678)
+++ branches/blender2.5/blender/source/blender/editors/space_console/console_intern.h	2009-07-18 16:27:25 UTC (rev 21679)
@@ -61,16 +61,11 @@
 void CONSOLE_OT_history_cycle(wmOperatorType *ot);
 void CONSOLE_OT_zoom(wmOperatorType *ot);
 
+/* DUMMY OPS. python will replace */
+void CONSOLE_OT_exec(wmOperatorType *ot);
+void CONSOLE_OT_autocomplete(wmOperatorType *ot);
+
 enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD };
 enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL };
 
-/* defined in DNA_space_types.h */
-static EnumPropertyItem console_line_type_items[] = {
-	{CONSOLE_LINE_OUTPUT,	"OUTPUT", 0, "Output", ""},
-	{CONSOLE_LINE_INPUT,	"INPUT", 0, "Input", ""},
-	{CONSOLE_LINE_INFO,		"INFO", 0, "Information", ""},
-	{CONSOLE_LINE_ERROR,	"ERROR", 0, "Error", ""},
-	{0, NULL, 0, NULL, NULL}};
-
 #endif /* ED_CONSOLE_INTERN_H */
-

Modified: branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c	2009-07-18 15:14:59 UTC (rev 21678)
+++ branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c	2009-07-18 16:27:25 UTC (rev 21679)
@@ -128,12 +128,14 @@
 	return console_lb_add__internal(&sc->history, from);
 }
 
+#if 0 /* may use later ? */
 static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
 	
 	return console_lb_add__internal(&sc->scrollback, from);
 }
+#endif
 
 static ConsoleLine *console_lb_add_str__internal(ListBase *lb, const bContext *C, char *str, int own)
 {
@@ -198,7 +200,7 @@
 	return len;
 }
 
-static int console_edit_poll(const bContext *C)
+static int console_edit_poll(bContext *C)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
 
@@ -221,7 +223,7 @@
 	{NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
 	{0, NULL, 0, NULL, NULL}};
 	
-static int move_exec(const bContext *C, wmOperator *op)
+static int move_exec(bContext *C, wmOperator *op)
 {
 	ConsoleLine *ci= console_history_verify(C);
 	
@@ -268,7 +270,7 @@
 }
 
 
-static int insert_exec(const bContext *C, wmOperator *op)
+static int insert_exec(bContext *C, wmOperator *op)
 {
 	ConsoleLine *ci= console_history_verify(C);
 	char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0);
@@ -285,7 +287,7 @@
 	return OPERATOR_FINISHED;
 }
 
-static int insert_invoke(const bContext *C, wmOperator *op, wmEvent *event)
+static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
 	if(!RNA_property_is_set(op->ptr, "text")) {
 		char str[2] = {event->ascii, '\0'};
@@ -320,7 +322,7 @@
 //	{DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
 	{0, NULL, 0, NULL, NULL}};
 
-static int delete_exec(const bContext *C, wmOperator *op)
+static int delete_exec(bContext *C, wmOperator *op)
 {
 	
 	ConsoleLine *ci= console_history_verify(C);
@@ -380,7 +382,7 @@
 
 
 /* the python exec operator uses this */
-static int clear_exec(const bContext *C, wmOperator *op)
+static int clear_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
 	
@@ -425,7 +427,7 @@
 
 
 /* the python exec operator uses this */
-static int history_cycle_exec(const bContext *C, wmOperator *op)
+static int history_cycle_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
 	ConsoleLine *ci= console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */
@@ -467,7 +469,7 @@
 
 
 /* the python exec operator uses this */
-static int history_append_exec(const bContext *C, wmOperator *op)
+static int history_append_exec(bContext *C, wmOperator *op)
 {
 	ConsoleLine *ci= console_history_verify(C);
 	
@@ -503,7 +505,7 @@
 
 
 /* the python exec operator uses this */
-static int scrollback_append_exec(const bContext *C, wmOperator *op)
+static int scrollback_append_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
 	ConsoleLine *ci= console_history_verify(C);
@@ -523,6 +525,14 @@
 
 void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
 {
+	/* defined in DNA_space_types.h */
+	static EnumPropertyItem console_line_type_items[] = {
+		{CONSOLE_LINE_OUTPUT,	"OUTPUT", 0, "Output", ""},
+		{CONSOLE_LINE_INPUT,	"INPUT", 0, "Input", ""},
+		{CONSOLE_LINE_INFO,		"INFO", 0, "Information", ""},
+		{CONSOLE_LINE_ERROR,	"ERROR", 0, "Error", ""},
+		{0, NULL, 0, NULL, NULL}};
+
 	/* identifiers */
 	ot->name= "Scrollback Append";
 	ot->idname= "CONSOLE_OT_scrollback_append";
@@ -539,7 +549,7 @@
 	RNA_def_enum(ot->srna, "type", console_line_type_items, CONSOLE_LINE_OUTPUT, "Type", "Console output type.");
 }
 
-static int zoom_exec(const bContext *C, wmOperator *op)
+static int zoom_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
 	
@@ -570,3 +580,16 @@
 	RNA_def_int(ot->srna, "delta", 0, 0, INT_MAX, "Delta", "Scale the view font.", 0, 1000);
 }
 
+/* Dummy operators, python will replace these, so blender can start without any errors */
+void CONSOLE_OT_exec(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "CONSOLE_OT_exec dummy";
+	ot->idname= "CONSOLE_OT_exec";
+}
+void CONSOLE_OT_autocomplete(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "CONSOLE_OT_autocomplete dummy";
+	ot->idname= "CONSOLE_OT_autocomplete";
+}

Modified: branches/blender2.5/blender/source/blender/editors/space_console/space_console.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_console/space_console.c	2009-07-18 15:14:59 UTC (rev 21678)
+++ branches/blender2.5/blender/source/blender/editors/space_console/space_console.c	2009-07-18 16:27:25 UTC (rev 21679)
@@ -215,6 +215,10 @@
 	WM_operatortype_append(CONSOLE_OT_clear); 
 	WM_operatortype_append(CONSOLE_OT_history_cycle);
 	WM_operatortype_append(CONSOLE_OT_zoom);
+
+	/* Dummy, defined in space_console.py */
+	WM_operatortype_append(CONSOLE_OT_exec);
+	WM_operatortype_append(CONSOLE_OT_autocomplete);
 }
 
 void console_keymap(struct wmWindowManager *wm)
@@ -345,10 +349,7 @@
 	art->draw= console_header_area_draw;
 	
 	BLI_addhead(&sc->regiontypes, art);
-	
-	
-	
+
+
 	BKE_spacetype_register(sc);
 }
-
-

Modified: branches/blender2.5/blender/source/blender/editors/space_text/space_text.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_text/space_text.c	2009-07-18 15:14:59 UTC (rev 21678)
+++ branches/blender2.5/blender/source/blender/editors/space_text/space_text.c	2009-07-18 16:27:25 UTC (rev 21679)
@@ -285,10 +285,6 @@
 	WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_ALT, 0);
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list