summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wildemann <gta04@metalstrolche.de>2017-01-26 01:30:29 +0100
committerStefan Wildemann <gta04@metalstrolche.de>2017-02-04 20:03:52 +0100
commit71050ec26497e2da13cee2ce2123c49de83cf049 (patch)
treedfcd1569b1366f0c873bff217a84054917156dcf
parentbd0092f3f6b30659a16cb19c3f468b6a8e3a0c21 (diff)
downloadnavit-71050ec26497e2da13cee2ce2123c49de83cf049.tar.gz
Fix: Qt5: allow passing Qt backend via config.xml
-rw-r--r--navit/attr_def.h2
-rw-r--r--navit/graphics/qt5/graphics_qt5.cpp35
-rw-r--r--navit/graphics/qt5/graphics_qt5.h5
3 files changed, 35 insertions, 7 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h
index b3f77163b..2b0bad448 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -281,7 +281,7 @@ ATTR_UNUSED
ATTR_UNUSED
ATTR_UNUSED
ATTR(window_title)
-ATTR_UNUSED
+ATTR(qt5_platform)
ATTR_UNUSED
/* poi */
ATTR_UNUSED
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
+