diff options
author | Stefan Wildemann <gta04@metalstrolche.de> | 2017-01-26 01:30:29 +0100 |
---|---|---|
committer | Stefan Wildemann <gta04@metalstrolche.de> | 2017-02-23 19:40:26 +0100 |
commit | 55b355180411f80618d8e2768b8810724e423518 (patch) | |
tree | a524033072885ebc7ef6c79f19ebf016bfd3194f /navit/graphics/qt5 | |
parent | 24c10862ac777f36bab1dd15bed8dd91cea7ae19 (diff) | |
download | navit-55b355180411f80618d8e2768b8810724e423518.tar.gz |
Fix: Qt5: allow passing Qt backend via config.xml
Diffstat (limited to 'navit/graphics/qt5')
-rw-r--r-- | navit/graphics/qt5/graphics_qt5.cpp | 35 | ||||
-rw-r--r-- | navit/graphics/qt5/graphics_qt5.h | 5 |
2 files changed, 34 insertions, 6 deletions
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp index 907702fdc..87fc82b63 100644 --- a/navit/graphics/qt5/graphics_qt5.cpp +++ b/navit/graphics/qt5/graphics_qt5.cpp @@ -90,6 +90,19 @@ graphics_destroy(struct graphics_priv *gr) #endif /* destroy overlays hash */ g_hash_table_destroy(gr->overlays); + /* destroy global application if destroying the last */ + if(gr->argc > 0 && navit_app != NULL) + { + delete (navit_app); + navit_app = NULL; + /* destroy argv if any */ + while(gr->argc > 0) + { + gr->argc --; + if(gr->argv[gr->argc] != NULL) + g_free(gr->argv[gr->argc]); + } + } /* destroy self */ g_free(gr); } @@ -701,6 +714,8 @@ overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct poin graphics_priv->use_count = 0; graphics_priv->parent = gr; graphics_priv->overlays=g_hash_table_new(NULL, NULL); + graphics_priv->argc=0; + graphics_priv->argv[0] = NULL; /* register on parent */ g_hash_table_insert(gr->overlays, graphics_priv, graphics_priv); // dbg(lvl_debug,"New overlay: %p\n", graphics_priv); @@ -708,15 +723,13 @@ overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct poin return graphics_priv; } -static int argc=3; -static char *argv[]={"navit","-platform","wayland", NULL}; - /* create application and initial graphics context */ static struct graphics_priv * graphics_qt5_new(struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl) { struct graphics_priv * graphics_priv = NULL; struct attr *event_loop_system = NULL; + struct attr * platform=NULL; *meth=graphics_methods; // dbg(lvl_debug,"enter\n"); @@ -730,6 +743,7 @@ graphics_qt5_new(struct navit *nav, struct graphics_methods *meth, struct attr * if (!event_request_system("qt5", "graphics_qt5")) return NULL; } + #ifdef QT_QPAINTER_USE_FREETYPE struct font_priv * (*font_freetype_new)(void *meth); /* get font plugin if present */ @@ -741,10 +755,21 @@ graphics_qt5_new(struct navit *nav, struct graphics_methods *meth, struct attr * #endif - /* create surrounding application */ - navit_app = new QApplication(argc, argv); /* create root graphics layer */ graphics_priv = g_new0(struct graphics_priv, 1); + /* Prepare QT argc and argv */ + graphics_priv->argc = 0; + graphics_priv->argv[graphics_priv->argc] = g_strdup("navit"); + graphics_priv->argc ++; + if ((platform=attr_search(attrs, NULL, attr_qt5_platform))) + { + graphics_priv->argv[graphics_priv->argc] = g_strdup("-platform"); + graphics_priv->argc ++; + graphics_priv->argv[graphics_priv->argc] = g_strdup(platform->u.str); + graphics_priv->argc ++; + } + /* create surrounding application */ + navit_app = new QApplication(graphics_priv->argc, graphics_priv->argv); #ifdef QT_QPAINTER_USE_FREETYPE graphics_priv->font_freetype_new=font_freetype_new; diff --git a/navit/graphics/qt5/graphics_qt5.h b/navit/graphics/qt5/graphics_qt5.h index 0f15a88fd..1f27ddfa0 100644 --- a/navit/graphics/qt5/graphics_qt5.h +++ b/navit/graphics/qt5/graphics_qt5.h @@ -40,6 +40,8 @@ struct graphics_priv { #endif GHashTable *overlays; struct graphics_priv * parent; + int argc; + char * argv[4]; }; struct graphics_gc_priv { @@ -56,4 +58,5 @@ extern struct callback_list* callbacks; void resize_callback(int w, int h); -#endif
\ No newline at end of file +#endif + |