From: H.G. Muller Date: Sun, 21 Oct 2012 07:48:29 +0000 (+0200) Subject: Print missing-pieces error message to console X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=604256ed14dc82406197376be74f9fe4d1d7f9da Print missing-pieces error message to console The GUI might not yet be up at this point.In addition, suppress the rest of the code, because it could give segfaults. --- diff --git a/draw.c b/draw.c index 9368227..7ec60ae 100644 --- a/draw.c +++ b/draw.c @@ -287,8 +287,13 @@ ScaleOnePiece (int color, int piece) } if(!pngPieceImages[color][piece]) { // we still did not manage to acquire a piece bitmap - if(!(svgPieces[color][piece] = LoadSVG(SVGDIR, color, piece))) // try to fall back on installed svg - DisplayError(_("No default pieces installed\nSelect your own -pieceImageDirectory"), 0); // give up + static int warned = 0; + if(!(svgPieces[color][piece] = LoadSVG(SVGDIR, color, piece)) && !warned) { // try to fall back on installed svg + char *msg = _("No default pieces installed\nSelect your own -pieceImageDirectory"); + printf("%s\n", msg); // give up + DisplayError(msg, 0); + warned = 1; // prevent error message being repeated for each piece type + } } img = pngPieceImages[color][piece]; @@ -298,6 +303,8 @@ ScaleOnePiece (int color, int piece) pngPieceBitmaps2[color][piece] = cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, squareSize, squareSize); if(piece <= WhiteKing) pngPieceBitmaps[color][piece] = cs; + if(!img) return; + // scaled copying of the raw png image cr = cairo_create(cs); w = cairo_image_surface_get_width (img);