diff options
author | sleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-07-13 20:37:21 +0000 |
---|---|---|
committer | sleske <sleske@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-07-13 20:37:21 +0000 |
commit | 9bf6351195580a917a8beaea8ae09b475733305b (patch) | |
tree | 348982a8ff4008983916195f9330f2eeb6cf6a4b | |
parent | 7c7753887db05491b0a5490c596eda4dfec88d36 (diff) | |
download | navit-9bf6351195580a917a8beaea8ae09b475733305b.tar.gz |
Fix:core:Integrate transform_setup into transform_new. Avoids two-step initialization and access to undefined variables in struct transform.|Part of fix for #1145.
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5544 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | navit/navit.c | 7 | ||||
-rw-r--r-- | navit/osd/core/osd_core.c | 3 | ||||
-rw-r--r-- | navit/transform.c | 25 | ||||
-rw-r--r-- | navit/transform.h | 2 | ||||
-rw-r--r-- | navit/vehicle.c | 3 |
5 files changed, 12 insertions, 28 deletions
diff --git a/navit/navit.c b/navit/navit.c index 1f75739ab..2a92f5a4a 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -1405,15 +1405,12 @@ navit_new(struct attr *parent, struct attr **attrs) this_->radius = 30; this_->border = 16; - this_->trans = transform_new(); - this_->trans_cursor = transform_new(); - transform_set_projection(this_->trans_cursor, pro); transform_from_geo(pro, &g, &co); center.x=co.x; center.y=co.y; center.pro = pro; - - transform_setup(this_->trans, ¢er, zoom, (this_->orientation != -1) ? this_->orientation : 0); + this_->trans = transform_new(¢er, zoom, (this_->orientation != -1) ? this_->orientation : 0); + this_->trans_cursor = transform_new(¢er, zoom, (this_->orientation != -1) ? this_->orientation : 0); this_->bookmarks=bookmarks_new(&this_->self, NULL, this_->trans); diff --git a/navit/osd/core/osd_core.c b/navit/osd/core/osd_core.c index fe0b1907f..cf9dcda7a 100644 --- a/navit/osd/core/osd_core.c +++ b/navit/osd/core/osd_core.c @@ -3555,6 +3555,7 @@ osd_auxmap_init(struct osd_priv_common *opc, struct navit *nav) struct graphics *gra; struct attr attr; struct map_selection sel; + struct pcoord center={ projection_mg, 0, 0}; struct color red={0xffff,0x0,0x0,0xffff}; this->nav=nav; @@ -3576,10 +3577,10 @@ osd_auxmap_init(struct osd_priv_common *opc, struct navit *nav) this->red=graphics_gc_new(gra); graphics_gc_set_foreground(this->red,&red); graphics_gc_set_linewidth(this->red,3); - this->trans=transform_new(); memset(&sel, 0, sizeof(sel)); sel.u.p_rect.rl.x=opc->osd_item.w; sel.u.p_rect.rl.y=opc->osd_item.h; + this->trans=transform_new(¢er, 16, 0); transform_set_screen_selection(this->trans, &sel); graphics_set_rect(opc->osd_item.gr, &sel.u.p_rect); #if 0 diff --git a/navit/transform.c b/navit/transform.c index 425fdd05b..b7949f095 100644 --- a/navit/transform.c +++ b/navit/transform.c @@ -169,21 +169,18 @@ transform_setup_matrix(struct transformation *t) } struct transformation * -transform_new(void) +transform_new(struct pcoord *center, int scale, int yaw) { struct transformation *this_; this_=g_new0(struct transformation, 1); transform_set_screen_dist(this_, 100); this_->order_base=14; -#if 0 - this_->pitch=20; -#endif -#if 0 - this_->roll=30; - this_->hog=1000; -#endif - transform_setup_matrix(this_); + this_->pro=center->pro; + this_->map_center.x=center->x; + this_->map_center.y=center->y; + this_->scale=scale/16.0; + transform_set_yaw(this_, yaw); return this_; } @@ -852,16 +849,6 @@ transform_get_size(struct transformation *t, int *width, int *height) } void -transform_setup(struct transformation *t, struct pcoord *c, int scale, int yaw) -{ - t->pro=c->pro; - t->map_center.x=c->x; - t->map_center.y=c->y; - t->scale=scale/16.0; - transform_set_yaw(t, yaw); -} - -void transform_setup_source_rect(struct transformation *t) { int i; diff --git a/navit/transform.h b/navit/transform.h index e7211cdf8..e58e136d5 100644 --- a/navit/transform.h +++ b/navit/transform.h @@ -39,7 +39,7 @@ struct map_selection; struct pcoord; struct point; struct transformation; -struct transformation *transform_new(void); +struct transformation *transform_new(struct pcoord *center, int scale, int yaw); int transform_get_hog(struct transformation *this_); void transform_set_hog(struct transformation *this_, int hog); int transform_get_attr(struct transformation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter); diff --git a/navit/vehicle.c b/navit/vehicle.c index a67779467..c28d5956c 100644 --- a/navit/vehicle.c +++ b/navit/vehicle.c @@ -126,11 +126,10 @@ vehicle_new(struct attr *parent, struct attr **attrs) } this_->attrs=attr_list_dup(attrs); - this_->trans=transform_new(); center.pro=projection_screen; center.x=0; center.y=0; - transform_setup(this_->trans, ¢er, 16, 0); + this_->trans=transform_new(¢er, 16, 0); vehicle_set_default_name(this_); dbg(1, "leave\n"); |