From 05942b77eab8ef1b7eb237654594300587c97aba Mon Sep 17 00:00:00 2001 From: martin-s Date: Fri, 7 Nov 2008 09:32:04 +0000 Subject: [PATCH] Fix:Core:Don't crash if no overlay is supported git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1666 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/cursor.c | 10 ++++++---- navit/navit/graphics.c | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/navit/navit/cursor.c b/navit/navit/cursor.c index 8738fa4..13dc210 100644 --- a/navit/navit/cursor.c +++ b/navit/navit/cursor.c @@ -119,10 +119,12 @@ cursor_draw(struct cursor *this_, struct graphics *gra, struct point *pnt, int l if (!this_->gra) { struct color c; this_->gra=graphics_overlay_new(gra, &this_->cursor_pnt, this_->w, this_->h, 65535); - this_->bg=graphics_gc_new(this_->gra); - c.r=0; c.g=0; c.b=0; c.a=0; - graphics_gc_set_foreground(this_->bg, &c); - graphics_background_gc(this_->gra, this_->bg); + if (this_->gra) { + this_->bg=graphics_gc_new(this_->gra); + c.r=0; c.g=0; c.b=0; c.a=0; + graphics_gc_set_foreground(this_->bg, &c); + graphics_background_gc(this_->gra, this_->bg); + } } cursor_draw_do(this_, lazy); } diff --git a/navit/navit/graphics.c b/navit/navit/graphics.c index f712893..d2faf4c 100644 --- a/navit/navit/graphics.c +++ b/navit/navit/graphics.c @@ -119,8 +119,14 @@ int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr * struct graphics * graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int alpha) { struct graphics *this_; + if (!parent->meth.overlay_new) + return NULL; this_=g_new0(struct graphics, 1); this_->priv=parent->meth.overlay_new(parent->priv, &this_->meth, p, w, h, alpha); + if (!this_->priv) { + g_free(this_); + this_=NULL; + } return this_; } -- 2.7.4