diff options
author | Stefan Wildemann <metalstrolch@metalstrolche.de> | 2015-12-03 09:16:04 +0100 |
---|---|---|
committer | Stefan Wildemann <gta04@metalstrolche.de> | 2017-02-23 19:40:26 +0100 |
commit | b96247eaf96ce2f8dd5069d5ec355ebc0f8affdd (patch) | |
tree | cc8b2f90287dfc095fb27915c2b4d2d4b63807b5 | |
parent | 7da72bcb7e72beb13d6bb8a2948987f420a76608 (diff) | |
download | navit-b96247eaf96ce2f8dd5069d5ec355ebc0f8affdd.tar.gz |
Improve dash handling. Cope with impair patterns.
-rw-r--r-- | navit/graphics/qt5/graphics_qt5.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp index 198bcb9c7..73095d759 100644 --- a/navit/graphics/qt5/graphics_qt5.cpp +++ b/navit/graphics/qt5/graphics_qt5.cpp @@ -140,6 +140,10 @@ gc_set_linewidth(struct graphics_gc_priv *gc, int w) static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n) { + if(n <= 0) + { + dbg(lvl_error, "Refuse to set dashes without dash pattern"); + } /* use Qt dash feature */ QVector<qreal> dashes; gc->pen->setWidth(w); @@ -148,6 +152,13 @@ gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *das { dashes << dash_list[a]; } + /* Qt requires the pattern to have even element count. Add the last + * element twice if n doesn't divide by two + */ + if((n % 2) != 0) + { + dashes << dash_list[n-1]; + } gc->pen->setDashPattern(dashes); } |