Skip to content

Commit

Permalink
avoiding exceptions when context was lost while creating filter or dr…
Browse files Browse the repository at this point in the history
…awing to RenderTexture (closes Gamua#642, closes Gamua#643)
  • Loading branch information
PrimaryFeather authored and Oldes committed Dec 3, 2014
1 parent a9c6266 commit ddb866b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions starling/src/starling/filters/FragmentFilter.as
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ package starling.filters

mIndexData = new <uint>[0, 1, 2, 1, 3, 2];
mIndexData.fixed = true;

createPrograms();

if (Starling.current.contextValid)
createPrograms();

// Handle lost context. By using the conventional event, we can make it weak; this
// avoids memory leaks when people forget to call "dispose" on the filter.
Expand Down
2 changes: 2 additions & 0 deletions starling/src/starling/textures/RenderTexture.as
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ package starling.textures
/*
var context:Context3D = Starling.context;
if (context == null) throw new MissingContextError();
if (!Starling.current.contextValid) return;
// switch buffers
if (isDoubleBuffered)
Expand Down Expand Up @@ -266,6 +267,7 @@ package starling.textures
{
var context:Context3D = Starling.context;
if (context == null) throw new MissingContextError();
if (!Starling.current.contextValid) return;

mSupport.renderTarget = mActiveTexture;
mSupport.clear(rgb, alpha);
Expand Down

0 comments on commit ddb866b

Please sign in to comment.