Fix:Core:Don't crash if no overlay is supported
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 7 Nov 2008 09:32:04 +0000 (09:32 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 7 Nov 2008 09:32:04 +0000 (09:32 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@1666 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/cursor.c
navit/navit/graphics.c

index 8738fa4..13dc210 100644 (file)
@@ -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);
 }
index f712893..d2faf4c 100644 (file)
@@ -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_;
 }