chiark / gitweb /
There seems to be some odd behaviour when GTK is asked to draw an
[sgt-puzzles.git] / gtk.c
diff --git a/gtk.c b/gtk.c
index 6fef7b864338bca15b12ec5cc498505331fa2e44..1cf5136043cf1fe6574e2830beaae13061a76915 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -373,7 +373,17 @@ void gtk_draw_poly(void *handle, int *coords, int npoints,
     }
     assert(outlinecolour >= 0);
     gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
-    gdk_draw_polygon(fe->pixmap, fe->gc, FALSE, points, npoints);
+
+    /*
+     * In principle we ought to be able to use gdk_draw_polygon for
+     * the outline as well. In fact, it turns out to interact badly
+     * with a clipping region, for no terribly obvious reason, so I
+     * draw the outline as a sequence of lines instead.
+     */
+    for (i = 0; i < npoints; i++)
+       gdk_draw_line(fe->pixmap, fe->gc,
+                     points[i].x, points[i].y,
+                     points[(i+1)%npoints].x, points[(i+1)%npoints].y);
 
     sfree(points);
 }
@@ -1447,8 +1457,9 @@ static frontend *new_window(char *arg, char **error)
                        " nor a save file (%.400s)", err, strerror(errno));
            } else {
                err = midend_deserialise(fe->me, savefile_read, fp);
-               sprintf(errbuf, "%.800s", err);
-               fclose(fp);
+                if (err)
+                    sprintf(errbuf, "%.800s", err);
+                fclose(fp);
            }
         }
        if (*errbuf) {