[tracker/tracker-0.10] miners/fs: Initialize QApplication object only once
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.10] miners/fs: Initialize QApplication object only once
- Date: Wed, 2 Mar 2011 14:45:01 +0000 (UTC)
commit 4c75a2dade4b9031fd8961b9e5e984d7d5395284
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Feb 21 12:26:10 2011 +0100
miners/fs: Initialize QApplication object only once
Fixes NB#228760.
src/miners/fs/tracker-miner-applications-meego.cpp | 32 ++++++++++++++-----
src/miners/fs/tracker-miner-applications-meego.h | 3 ++
src/miners/fs/tracker-miner-applications.c | 16 +++++++++-
3 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-applications-meego.cpp b/src/miners/fs/tracker-miner-applications-meego.cpp
index 30a7af3..09c1fa6 100644
--- a/src/miners/fs/tracker-miner-applications-meego.cpp
+++ b/src/miners/fs/tracker-miner-applications-meego.cpp
@@ -26,6 +26,24 @@
#include "tracker-miner-applications-meego.h"
+static QCoreApplication *app = NULL;
+
+void
+tracker_miner_applications_meego_init (void)
+{
+ char *argv[] = { "dummy", NULL };
+ int argc = 1;
+
+ /* We need the app for loading translations */
+ app = new QApplication (argc, argv, FALSE);
+}
+
+void
+tracker_miner_applications_meego_shutdown (void)
+{
+ delete app;
+}
+
/* The meego desktop files are using the qt translation system to get
* localized strings using catalog and string ids. QApplication and
* MLocale are needed for loading the translation catalogs. The
@@ -39,18 +57,14 @@ gchar *
tracker_miner_applications_meego_translate (const gchar *catalogue,
const gchar *id)
{
- char *argv[] = { "dummy", NULL };
- int argc = 1;
-
- /* We need the app for loading translations */
- QApplication app (argc, argv, FALSE);
-
/* Get the system default locale */
MLocale locale;
- /* Load the catalog from disk */
- locale.installTrCatalog (catalogue);
- MLocale::setDefault (locale);
+ /* Load the catalog from disk if not already there */
+ if(!locale.isInstalledTrCatalog (catalogue)) {
+ locale.installTrCatalog (catalogue);
+ MLocale::setDefault (locale);
+ }
gchar *ret = g_strdup (qtTrId (id).toUtf8 ().data ());
diff --git a/src/miners/fs/tracker-miner-applications-meego.h b/src/miners/fs/tracker-miner-applications-meego.h
index d3688ee..b4fdab9 100644
--- a/src/miners/fs/tracker-miner-applications-meego.h
+++ b/src/miners/fs/tracker-miner-applications-meego.h
@@ -27,6 +27,9 @@ gchar *tracker_miner_applications_meego_translate (const gchar *catalogue,
gchar *tracker_miner_applications_meego_get_locale (void);
+void tracker_miner_applications_meego_init (void);
+void tracker_miner_applications_meego_shutdown (void);
+
G_END_DECLS
#endif /* __TRACKER_MINER_FS_APPLICATIONS_MEEGO_H__ */
diff --git a/src/miners/fs/tracker-miner-applications.c b/src/miners/fs/tracker-miner-applications.c
index 1c152d0..14b54cf 100644
--- a/src/miners/fs/tracker-miner-applications.c
+++ b/src/miners/fs/tracker-miner-applications.c
@@ -55,6 +55,8 @@ static gboolean miner_applications_process_file_attributes (TrackerMinerFS
GCancellable *cancellable);
static gboolean miner_applications_monitor_directory (TrackerMinerFS *fs,
GFile *file);
+static void miner_applications_finalize (GObject *object);
+
static GQuark miner_applications_error_quark = 0;
@@ -78,8 +80,11 @@ G_DEFINE_TYPE_WITH_CODE (TrackerMinerApplications, tracker_miner_applications, T
static void
tracker_miner_applications_class_init (TrackerMinerApplicationsClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
TrackerMinerFSClass *miner_fs_class = TRACKER_MINER_FS_CLASS (klass);
+ object_class->finalize = miner_applications_finalize;
+
miner_fs_class->check_file = miner_applications_check_file;
miner_fs_class->check_directory = miner_applications_check_directory;
miner_fs_class->monitor_directory = miner_applications_monitor_directory;
@@ -132,6 +137,7 @@ miner_applications_initable_init (GInitable *initable,
file = g_file_new_for_path ("/usr/lib/duicontrolpanel/");
tracker_miner_fs_directory_add (fs, file, TRUE);
g_object_unref (file);
+ tracker_miner_applications_meego_init ();
#endif /* HAVE_MEEGOTOUCH */
/* FIXME: Check XDG_DATA_DIRS and also process applications in there */
@@ -140,6 +146,14 @@ miner_applications_initable_init (GInitable *initable,
}
static void
+miner_applications_finalize (GObject *object)
+{
+#ifdef HAVE_MEEGOTOUCH
+ tracker_miner_applications_meego_shutdown ();
+#endif /* HAVE_MEEGOTOUCH */
+}
+
+static void
insert_data_from_desktop_file (TrackerSparqlBuilder *sparql,
const gchar *subject,
const gchar *metadata_key,
@@ -736,7 +750,7 @@ miner_applications_process_file (TrackerMinerFS *fs,
G_FILE_ATTRIBUTE_STANDARD_TYPE;
g_file_query_info_async (file,
- attrs,
+ attrs,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
G_PRIORITY_DEFAULT,
cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]