[tracker] tracker-extract: Workaround for Qt bug when no QApplication is constructed



commit c8d60ee0042c746a65560a54c02f4c954d5ad1e6
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Feb 1 12:00:05 2011 +0100

    tracker-extract: Workaround for Qt bug when no QApplication is constructed
    
    For the QImage class a QApplication must be constructed in order for SVG
    files to work without crashing in font configuration loading in Qt.
    
    Fixes NB#223938.

 src/tracker-extract/tracker-albumart-dummy.c   |   10 ++++++++++
 src/tracker-extract/tracker-albumart-generic.h |   15 +++++++++------
 src/tracker-extract/tracker-albumart-pixbuf.c  |   10 ++++++++++
 src/tracker-extract/tracker-albumart-qt.cpp    |   18 ++++++++++++++++++
 src/tracker-extract/tracker-albumart.c         |    4 ++++
 5 files changed, 51 insertions(+), 6 deletions(-)
---
diff --git a/src/tracker-extract/tracker-albumart-dummy.c b/src/tracker-extract/tracker-albumart-dummy.c
index 04110ba..6b1bc27 100644
--- a/src/tracker-extract/tracker-albumart-dummy.c
+++ b/src/tracker-extract/tracker-albumart-dummy.c
@@ -22,6 +22,16 @@
 
 #include "tracker-albumart-generic.h"
 
+void
+tracker_albumart_plugin_init (void)
+{
+}
+
+void
+tracker_albumart_plugin_shutdown (void)
+{
+}
+
 gboolean
 tracker_albumart_file_to_jpeg (const gchar *filename,
                                const gchar *target)
diff --git a/src/tracker-extract/tracker-albumart-generic.h b/src/tracker-extract/tracker-albumart-generic.h
index 1856876..cd5a9b2 100644
--- a/src/tracker-extract/tracker-albumart-generic.h
+++ b/src/tracker-extract/tracker-albumart-generic.h
@@ -27,12 +27,15 @@
 
 G_BEGIN_DECLS
 
-gboolean  tracker_albumart_file_to_jpeg   (const gchar         *filename,
-                                           const gchar         *target);
-gboolean  tracker_albumart_buffer_to_jpeg (const unsigned char *buffer,
-                                           size_t               len,
-                                           const gchar         *buffer_mime,
-                                           const gchar         *target);
+void      tracker_albumart_plugin_init     (void);
+void      tracker_albumart_plugin_shutdown (void);
+
+gboolean  tracker_albumart_file_to_jpeg    (const gchar         *filename,
+                                            const gchar         *target);
+gboolean  tracker_albumart_buffer_to_jpeg  (const unsigned char *buffer,
+                                            size_t               len,
+                                            const gchar         *buffer_mime,
+                                            const gchar         *target);
 
 G_END_DECLS
 
diff --git a/src/tracker-extract/tracker-albumart-pixbuf.c b/src/tracker-extract/tracker-albumart-pixbuf.c
index e287bf9..fd743ba 100644
--- a/src/tracker-extract/tracker-albumart-pixbuf.c
+++ b/src/tracker-extract/tracker-albumart-pixbuf.c
@@ -24,6 +24,16 @@
 
 #include "tracker-albumart-generic.h"
 
+void
+tracker_albumart_plugin_init (void)
+{
+}
+
+void
+tracker_albumart_plugin_shutdown (void)
+{
+}
+
 gboolean
 tracker_albumart_file_to_jpeg (const gchar *filename,
                                const gchar *target)
diff --git a/src/tracker-extract/tracker-albumart-qt.cpp b/src/tracker-extract/tracker-albumart-qt.cpp
index 042d597..d00b65c 100644
--- a/src/tracker-extract/tracker-albumart-qt.cpp
+++ b/src/tracker-extract/tracker-albumart-qt.cpp
@@ -25,6 +25,7 @@
 #include <QBuffer>
 #include <QImageReader>
 #include <QImageWriter>
+#include <QApplication>
 
 #include <glib.h>
 
@@ -32,6 +33,23 @@
 
 G_BEGIN_DECLS
 
+static QApplication *app = NULL;
+
+void
+tracker_albumart_plugin_init (void)
+{
+	int argc = 0;
+	char **argv = NULL;
+
+	app = new QApplication (argc, argv);
+}
+
+void
+tracker_albumart_plugin_shutdown (void)
+{
+	delete app;
+}
+
 gboolean
 tracker_albumart_file_to_jpeg (const gchar *filename,
                                const gchar *target)
diff --git a/src/tracker-extract/tracker-albumart.c b/src/tracker-extract/tracker-albumart.c
index e0c7cc2..fb84d0a 100644
--- a/src/tracker-extract/tracker-albumart.c
+++ b/src/tracker-extract/tracker-albumart.c
@@ -702,6 +702,8 @@ tracker_albumart_init (void)
 
 	g_return_val_if_fail (initialized == FALSE, FALSE);
 
+	tracker_albumart_plugin_init ();
+
 	albumart_storage = tracker_storage_new ();
 
 	/* Cache to know if we have already handled uris */
@@ -742,6 +744,8 @@ tracker_albumart_shutdown (void)
 		g_object_unref (albumart_storage);
 	}
 
+	tracker_albumart_plugin_shutdown ();
+
 	initialized = FALSE;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]