• R/O
  • SSH
  • HTTPS

dxruby: Commit


Commit MetaInfo

Revision527 (tree)
Time2016-04-29 17:37:02
Authormirichi

Log Message

RenderTargetのGCまわりでSEGVする問題修正

Change Summary

Incremental Difference

--- branches/1.5dev/dxruby.c (revision 526)
+++ branches/1.5dev/dxruby.c (revision 527)
@@ -179,6 +179,7 @@
179179 static void Window_setDefaultIcon( void );
180180 static void Window_createCircleShader(void);
181181 static void Window_createCircleFillShader(void);
182+static void CleanRenderTargetList( void );
182183
183184 /*********************************************************************
184185 * Windowモジュール
@@ -559,17 +560,21 @@
559560 // デバイスロストから復帰した
560561 if( ret == 0 )
561562 {
563+ rb_gc_start();
562564 for( i = 0; i < g_RenderTargetList.count; i++ )
563565 {
564- struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i];
566+ if( g_RenderTargetList.pointer[i] )
567+ {
568+ struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i];
565569 #ifdef DXRUBY15
566- // 再生成Procが設定されている場合
567- if( rt->vregenerate_proc != Qnil )
568- {
569- rb_funcall( rt->vregenerate_proc, SYM2ID( symbol_call ), 0 );
570- rt->clearflag = 0;
570+ // 再生成Procが設定されている場合
571+ if( rt->vregenerate_proc != Qnil )
572+ {
573+ rb_funcall( rt->vregenerate_proc, SYM2ID( symbol_call ), 0 );
574+ rt->clearflag = 0;
575+ }
576+#endif
571577 }
572-#endif
573578 }
574579 }
575580
@@ -582,37 +587,12 @@
582587 rt->PictureDecideSize = 0;
583588 for( i = 0; i < RARRAY_LEN(rt->varray); i++ )
584589 {
585-// Image_dispose( RARRAY_PTR(rt->array)[i] );
586590 Image_dispose( RARRAY_AREF(rt->varray, i) );
587591 }
588592 rb_ary_clear( rt->varray );
589593 }
590594
591- // RenderTargetに関連付けられた内部生成Imageの破棄
592- for( i = 0; i < g_RenderTargetList.count; i++ )
593- {
594- struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i];
595- int j;
596- rt->PictureCount = 0;
597- rt->PictureSize = 0;
598- rt->PictureDecideCount = 0;
599- rt->PictureDecideSize = 0;
600-#ifdef DXRUBY15
601- if( rt->vregenerate_proc == Qnil )
602- {
603- rt->clearflag = 0;
604- }
605-#else
606- rt->clearflag = 0;
607-#endif
608- for( j = 0; j < RARRAY_LEN(rt->varray); j++ )
609- {
610-// Image_dispose( RARRAY_PTR(rt->array)[j] );
611- Image_dispose( RARRAY_AREF(rt->varray, j) );
612- }
613- rb_ary_clear( rt->varray );
614- }
615-
595+ CleanRenderTargetList();
616596 g_RunningTime = GetSystemCounter() - g_StartTime;
617597
618598 g_WindowInfo.input_updated = 0;
@@ -2184,23 +2164,34 @@
21842164 {
21852165 if( g_RenderTargetList.pointer[i] == rt )
21862166 {
2167+ g_RenderTargetList.pointer[i] = NULL;
21872168 break;
21882169 }
21892170 }
2190-// if( i == g_RenderTargetList.count )
2191-// {
2192-// rb_raise( eDXRubyError, "内部エラー - DeleteRenderTargetList" );
2193-// }
2171+}
21942172
2195- i++;
2196- for( ; i < g_RenderTargetList.count; i++ )
2173+static void CleanRenderTargetList( void )
2174+{
2175+ int i, j;
2176+
2177+ for( i = 0, j = 0; j < g_RenderTargetList.count; )
21972178 {
2198- g_RenderTargetList.pointer[i - 1] = g_RenderTargetList.pointer[i];
2179+ if( g_RenderTargetList.pointer[j] == NULL )
2180+ {
2181+ j++;
2182+ }
2183+ else
2184+ {
2185+ g_RenderTargetList.pointer[i] = g_RenderTargetList.pointer[j];
2186+ i++;
2187+ j++;
2188+ }
21992189 }
22002190
2201- g_RenderTargetList.count--;
2191+ g_RenderTargetList.count = i;
22022192 }
22032193
2194+
22042195 /*--------------------------------------------------------------------
22052196 参照されなくなったときにGCから呼ばれる関数
22062197 ---------------------------------------------------------------------*/
@@ -4447,7 +4438,10 @@
44474438 RenderTarget_drawEx( 4, arr, obj );
44484439 }
44494440
4450- rb_ary_push( rt->varray, vimage );
4441+ {
4442+ struct DXRubyRenderTarget *grt = DXRUBY_GET_STRUCT( RenderTarget, g_WindowInfo.render_target );
4443+ rb_ary_push( grt->varray, vimage );
4444+ }
44514445
44524446 return obj;
44534447 }
@@ -5061,11 +5055,6 @@
50615055 rt->PictureSize = 0;
50625056 rt->PictureDecideCount = 0;
50635057 rt->PictureDecideSize = 0;
5064- for( i = 0; i < RARRAY_LEN(rt->varray); i++ )
5065- {
5066- Image_dispose( RARRAY_AREF(rt->varray, i) );
5067- }
5068- rb_ary_clear( rt->varray );
50695058
50705059 return self;
50715060 }
Show on old repository browser