From 604256ed14dc82406197376be74f9fe4d1d7f9da Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 21 Oct 2012 09:48:29 +0200 Subject: [PATCH] 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. --- draw.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) 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); -- 1.7.0.4