tags 387209 patch
quit
On Tue, Sep 12, 2006 at 11:36:07PM +0100, Colin S. Miller wrote:
> Package: cgoban
> Version: 1.9.14-11
> Severity: important
> 
> When I try to maximize cgoban's board window, cgoban will crash with
> X Error of failed request:  BadAlloc (insufficient resources for operation)
>   Major opcode of failed request:  53 (X_CreatePixmap)
>   Serial number of failed request:  58056
>   Current serial number in output stream:  58500
> 
> My screen resolution is 1280x1024 24bpp, 75Hz,
> under KDE.
> 
> cgoban will not crash if it resized to almost the full screen resolution
> before being maximized.

Hello Colin and Martin,
it seems cgoban expect the window height to be larger than the window width when
deciding on the size of the goban. This cause cgoban to attempt to draw a pixmap
with negative height, which is forbidden by Xlib.

The attached patch (fix-2) fix that by using the minimum of the height and the 
width.

Cheers,
-- 
Bill. <[email protected]>

Imagine a large red swirl here. 
Index: cgoban-1.9.14/src/goban.c
===================================================================
--- cgoban-1.9.14.orig/src/goban.c      2012-05-03 22:12:43.000000000 +0200
+++ cgoban-1.9.14/src/goban.c   2012-05-03 22:57:40.000000000 +0200
@@ -256,6 +256,7 @@
   butWin_destroy(g->win);
 }
 
+static int minss(int x, int y) { return x<y ? x:y; }
 
 static ButOut  resize(ButWin *win)  {
   Goban  *g = butWin_packet(win);
@@ -277,7 +278,7 @@
   winH = butWin_h(win);
   fontH = cg->fontH;
   butW = fontH * 10 + bw*4;
-  boardW = winW - butW - fontH*3 - bw*2;
+  boardW = minss(winW - butW - fontH*3 - bw*2, winH - fontH*11 - bw*4);
   clpEntry_setDouble(g->bProp, (double)winH / (double)butWin_getMinH(win));
   clpEntry_setDouble(g->bPropW, (double)winW / 
(double)butWin_getMinW(win)/2.0);
 

Reply via email to