View Issue Details

IDProjectCategoryView StatusLast Update
0001949FSSCPscriptingpublic2009-08-07 16:52
ReporterAardwolf Assigned Toportej05  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.11 
Summary0001949: Assertion in gr.drawTargetingBrackets (patch included)
DescriptionAn assertion was causing gr.drawTargetingBrackets to crash in Debug builds, possibly Release as well. The problem happened because g3_start_frame(0) was being called, but there were places where the function could return before getting to the matching g3_end_frame();
Additional InformationThe patch should fix this. See attached file.
TagsNo tags attached.

Activities

2009-07-03 14:40

 

targetingbrackets_crash_fix.patch (1,427 bytes)   
Index: lua.cpp
===================================================================
--- lua.cpp	(revision 5392)
+++ lua.cpp	(working copy)
@@ -8447,11 +8447,20 @@
 	int bound_rc, pof;
 	int modelnum;
 
+	bool not_in_frame = !(g3_in_frame() > 0);
+
+	if( not_in_frame ) {
+		g3_start_frame(0);
+	}
+
 	switch ( targetp->type ) {
 		case OBJ_SHIP:
 			modelnum = Ship_info[Ships[targetp->instance].ship_info_index].model_num;
 			bound_rc = model_find_2d_bound_min( modelnum, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 );
 			if ( bound_rc != 0 ) {
+				if( not_in_frame ) {
+					g3_end_frame();
+				}
 				return ADE_RETURN_NIL;
 			}
 			break;
@@ -8459,6 +8468,9 @@
 			modelnum = Debris[targetp->instance].model_num;
 			bound_rc = submodel_find_2d_bound_min( modelnum, Debris[targetp->instance].submodel_num, &targetp->orient, &targetp->pos,&x1,&y1,&x2,&y2 );
 			if ( bound_rc != 0 ) {
+				if( not_in_frame ) {
+					g3_end_frame();
+				}
 				return ADE_RETURN_NIL;
 			}
 			break;
@@ -8487,15 +8499,11 @@
 	y1 -= padding;
 	y2 += padding;
 	if ( draw_box ) {
-		if( !(g3_in_frame() > 0) ) {
-			g3_start_frame(0);
-			draw_brackets_square(x1, y1, x2, y2, false);
-			g3_end_frame();
-		}
-		else {
-			draw_brackets_square(x1, y1, x2, y2, false);
-		}
+		draw_brackets_square(x1, y1, x2, y2, false);
 	}
+	if( not_in_frame ) {
+		g3_end_frame();
+	}
 
 	return ade_set_args(L, "iiii", x1, y1, x2, y2);
 }

portej05

2009-07-03 15:36

reporter   ~0011034

Patch from Aardwolf modified slightly and committed.
Aardwolf reports patch works as intended.

Aardwolf

2009-08-06 21:24

reporter   ~0011125

No additional feedback?

portej05

2009-08-07 16:52

reporter   ~0011128

I believe not - closing. This appears to be fixed.

Issue History

Date Modified Username Field Change
2009-07-03 14:40 Aardwolf New Issue
2009-07-03 14:40 Aardwolf Status new => assigned
2009-07-03 14:40 Aardwolf Assigned To => WMCoolmon
2009-07-03 14:40 Aardwolf File Added: targetingbrackets_crash_fix.patch
2009-07-03 14:48 portej05 Assigned To WMCoolmon =>
2009-07-03 14:48 portej05 Status assigned => new
2009-07-03 15:35 portej05 Status new => assigned
2009-07-03 15:35 portej05 Assigned To => portej05
2009-07-03 15:36 portej05 Note Added: 0011034
2009-07-03 15:36 portej05 Status assigned => feedback
2009-08-06 21:24 Aardwolf Note Added: 0011125
2009-08-07 16:52 portej05 Status feedback => resolved
2009-08-07 16:52 portej05 Resolution open => fixed
2009-08-07 16:52 portej05 Note Added: 0011128