| Date: Sat, 15 Aug 2009 02:34:42 -0400
page: add missing delayfreeimage calls
fixes #19 http://code.swtch.com/plan9port/issue/19
http://codereview.appspot.com/108041
Diffstat:
M src/cmd/page/view.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
--- |
| t@@ -18,6 +18,7 @@
Document *doc;
Mousectl *mc;
Image *im;
+Image *tofree;
int page;
int angle = 0;
int showbottom = 0; /* on the next showpage, move the image so the bottom is visible. */
t@@ -62,6 +63,16 @@ enum {
RMenu = 3,
};
+static void
+delayfreeimage(Image *m)
+{
+ if(m == tofree)
+ return;
+ if(tofree)
+ freeimage(tofree);
+ tofree = m;
+}
+
void
unhide(void)
{
t@@ -121,6 +132,7 @@ showpage(int page, Menu *m)
m->lasthit = reverse ? doc->npage-1-page : page;
setcursor(mc, &reading);
+ delayfreeimage(nil);
im = cachedpage(doc, angle, page);
if(im == nil)
wexits(0);
t@@ -553,8 +565,8 @@ viewer(Document *dd)
wexits("memory");
}
resample(im, tmp);
- freeimage(im);
im = tmp;
+ delayfreeimage(tmp);
setcursor(mc, nil);
ul = screen->r.min;
redraw(screen);
t@@ -578,8 +590,8 @@ viewer(Document *dd)
wexits("memory");
}
resample(im, tmp);
- freeimage(im);
im = tmp;
+ delayfreeimage(tmp);
setcursor(mc, nil);
ul = screen->r.min;
redraw(screen); |