From 352b3d3d6de884fc8db10b464945140d1b28cb7b Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 2 May 2003 23:54:56 +0000 Subject: [PATCH] We need to dispose of the graphics that we obtain from getDrawGraphics(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2536 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/media/FlipFrameManager.java | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/java/com/threerings/media/FlipFrameManager.java b/src/java/com/threerings/media/FlipFrameManager.java index 290de04ff..0b3564ff7 100644 --- a/src/java/com/threerings/media/FlipFrameManager.java +++ b/src/java/com/threerings/media/FlipFrameManager.java @@ -1,5 +1,5 @@ // -// $Id: FlipFrameManager.java,v 1.2 2003/05/01 22:06:52 mdb Exp $ +// $Id: FlipFrameManager.java,v 1.3 2003/05/02 23:54:56 mdb Exp $ package com.threerings.media; @@ -35,28 +35,37 @@ public class FlipFrameManager extends FrameManager boolean incremental = true; do { - Graphics2D gfx = (Graphics2D)_bufstrat.getDrawGraphics(); + Graphics2D gfx = null; + try { + gfx = (Graphics2D)_bufstrat.getDrawGraphics(); - // dirty everything if we're not incrementally rendering - if (!incremental) { - Log.info("Doing non-incremental render; contents lost."); - _frame.getRootPane().revalidate(); - _frame.getRootPane().repaint(); + // dirty everything if we're not incrementally rendering + if (!incremental) { + Log.info("Doing non-incremental render; contents lost " + + "[lost=" + _bufstrat.contentsLost() + + ", rest=" + _bufstrat.contentsRestored() + "]."); + _frame.getRootPane().revalidate(); + _frame.getRootPane().repaint(); + } + + // request to paint our participants and components and bail + // if they paint nothing + if (!paint(gfx)) { + return; + } + + // flip our buffer to visible + _bufstrat.show(); + + // if we loop through a second time, we'll need to rerender + // everything + incremental = false; + + } finally { + if (gfx != null) { + gfx.dispose(); + } } - - // request to paint our participants and components and bail - // if they paint nothing - if (!paint(gfx)) { - return; - } - - // flip our buffer to visible - _bufstrat.show(); - - // if we loop through a second time, we'll need to rerender - // everything - incremental = false; - } while (_bufstrat.contentsLost()); }