patch to latest git, fixes some memory leak and crash issues

This commit is contained in:
Adam Williamson 2014-01-08 15:27:44 -08:00
parent ada2b6749d
commit 424514fd65
2 changed files with 449 additions and 1 deletions

View File

@ -0,0 +1,442 @@
diff --git a/libmenu/desktop-entries.c b/libmenu/desktop-entries.c
index 1e23bf2..a8c13d9 100644
--- a/libmenu/desktop-entries.c
+++ b/libmenu/desktop-entries.c
@@ -406,7 +406,7 @@ desktop_entry_ref (DesktopEntry *entry)
g_return_val_if_fail (entry != NULL, NULL);
g_return_val_if_fail (entry->refcount > 0, NULL);
- g_atomic_int_inc (&entry->refcount);
+ entry->refcount += 1;
return entry;
}
@@ -699,7 +699,7 @@ desktop_entry_set_ref (DesktopEntrySet *set)
g_return_val_if_fail (set != NULL, NULL);
g_return_val_if_fail (set->refcount > 0, NULL);
- g_atomic_int_inc (&set->refcount);
+ set->refcount += 1;
return set;
}
@@ -707,13 +707,11 @@ desktop_entry_set_ref (DesktopEntrySet *set)
void
desktop_entry_set_unref (DesktopEntrySet *set)
{
- gboolean is_zero;
-
g_return_if_fail (set != NULL);
g_return_if_fail (set->refcount > 0);
- is_zero = g_atomic_int_dec_and_test (&set->refcount);
- if (is_zero)
+ set->refcount -= 1;
+ if (set->refcount == 0)
{
menu_verbose (" Deleting entry set %p\n", set);
diff --git a/libmenu/entry-directories.c b/libmenu/entry-directories.c
index 67869b4..c827f84 100644
--- a/libmenu/entry-directories.c
+++ b/libmenu/entry-directories.c
@@ -40,12 +40,12 @@ struct EntryDirectory
guint entry_type : 2;
guint is_legacy : 1;
- volatile gint refcount;
+ guint refcount : 24;
};
struct EntryDirectoryList
{
- volatile int refcount;
+ int refcount;
int length;
GList *dirs;
};
@@ -64,10 +64,10 @@ struct CachedDir
guint have_read_entries : 1;
guint deleted : 1;
+ guint references;
+
GFunc notify;
gpointer notify_data;
-
- volatile gint references;
};
struct CachedDirMonitor
@@ -83,6 +83,7 @@ static void cached_dir_free (CachedDir *dir);
static gboolean cached_dir_load_entries_recursive (CachedDir *dir,
const char *dirname);
static void cached_dir_unref (CachedDir *dir);
+static void cached_dir_unref_noparent (CachedDir *dir);
static CachedDir * cached_dir_add_subdir (CachedDir *dir,
const char *basename,
const char *path);
@@ -156,7 +157,7 @@ cached_dir_free (CachedDir *dir)
dir->entries = NULL;
g_slist_foreach (dir->subdirs,
- (GFunc) cached_dir_unref,
+ (GFunc) cached_dir_unref_noparent,
NULL);
g_slist_free (dir->subdirs);
dir->subdirs = NULL;
@@ -168,18 +169,14 @@ cached_dir_free (CachedDir *dir)
static CachedDir *
cached_dir_ref (CachedDir *dir)
{
- g_atomic_int_inc (&dir->references);
-
+ dir->references++;
return dir;
}
static void
cached_dir_unref (CachedDir *dir)
{
- gboolean is_zero;
-
- is_zero = g_atomic_int_dec_and_test (&dir->references);
- if (is_zero)
+ if (--dir->references == 0)
{
CachedDir *parent;
@@ -195,6 +192,18 @@ cached_dir_unref (CachedDir *dir)
}
}
+static void
+cached_dir_unref_noparent (CachedDir *dir)
+{
+ if (--dir->references == 0)
+ {
+ if (dir->notify)
+ dir->notify (dir, dir->notify_data);
+
+ cached_dir_free (dir);
+ }
+}
+
static inline CachedDir *
find_subdir (CachedDir *dir,
const char *subdir)
@@ -224,13 +233,8 @@ find_entry (CachedDir *dir,
tmp = dir->entries;
while (tmp != NULL)
{
- const char *entry_basename;
-
- entry_basename = desktop_entry_get_basename (tmp->data);
- if (strcmp (entry_basename, basename) == 0)
- {
- return tmp->data;
- }
+ if (strcmp (desktop_entry_get_basename (tmp->data), basename) == 0)
+ return tmp->data;
tmp = tmp->next;
}
@@ -334,9 +338,7 @@ cached_dir_update_entry (CachedDir *dir,
tmp = dir->entries;
while (tmp != NULL)
{
- const char *entry_basename;
- entry_basename = desktop_entry_get_basename (tmp->data);
- if (strcmp (entry_basename, basename) == 0)
+ if (strcmp (desktop_entry_get_basename (tmp->data), basename) == 0)
{
if (!desktop_entry_reload (tmp->data))
{
@@ -361,10 +363,7 @@ cached_dir_remove_entry (CachedDir *dir,
tmp = dir->entries;
while (tmp != NULL)
{
- const char *entry_basename;
- entry_basename = desktop_entry_get_basename (tmp->data);
-
- if (strcmp (entry_basename, basename) == 0)
+ if (strcmp (desktop_entry_get_basename (tmp->data), basename) == 0)
{
desktop_entry_unref (tmp->data);
dir->entries = g_slist_delete_link (dir->entries, tmp);
@@ -420,11 +419,8 @@ cached_dir_remove_subdir (CachedDir *dir,
{
subdir->deleted = TRUE;
- if (subdir->references == 0)
- {
- cached_dir_unref (subdir);
- dir->subdirs = g_slist_remove (dir->subdirs, subdir);
- }
+ cached_dir_unref (subdir);
+ dir->subdirs = g_slist_remove (dir->subdirs, subdir);
return TRUE;
}
@@ -528,16 +524,11 @@ handle_cached_dir_changed (MenuMonitor *monitor,
char *basename;
char *dirname;
- menu_verbose ("'%s' notified of '%s' %s - invalidating cache\n",
- dir->name,
- path,
- event == MENU_MONITOR_EVENT_CREATED ? ("created") :
- event == MENU_MONITOR_EVENT_DELETED ? ("deleted") : ("changed"));
-
dirname = g_path_get_dirname (path);
basename = g_path_get_basename (path);
dir = cached_dir_lookup (dirname);
+ cached_dir_add_reference (dir);
if (g_str_has_suffix (basename, ".desktop") ||
g_str_has_suffix (basename, ".directory"))
@@ -558,7 +549,7 @@ handle_cached_dir_changed (MenuMonitor *monitor,
break;
}
}
- else /* Try recursing */
+ else if (g_file_test (path, G_FILE_TEST_IS_DIR)) /* Try recursing */
{
switch (event)
{
@@ -584,6 +575,12 @@ handle_cached_dir_changed (MenuMonitor *monitor,
if (handled)
{
+ menu_verbose ("'%s' notified of '%s' %s - invalidating cache\n",
+ dir->name,
+ path,
+ event == MENU_MONITOR_EVENT_CREATED ? ("created") :
+ event == MENU_MONITOR_EVENT_DELETED ? ("deleted") : ("changed"));
+
/* CHANGED events don't change the set of desktop entries */
if (event == MENU_MONITOR_EVENT_CREATED || event == MENU_MONITOR_EVENT_DELETED)
{
@@ -592,6 +589,8 @@ handle_cached_dir_changed (MenuMonitor *monitor,
cached_dir_queue_monitor_event (dir);
}
+
+ cached_dir_remove_reference (dir);
}
static void
@@ -822,7 +821,7 @@ entry_directory_ref (EntryDirectory *ed)
g_return_val_if_fail (ed != NULL, NULL);
g_return_val_if_fail (ed->refcount > 0, NULL);
- g_atomic_int_inc (&ed->refcount);
+ ed->refcount++;
return ed;
}
@@ -830,13 +829,10 @@ entry_directory_ref (EntryDirectory *ed)
void
entry_directory_unref (EntryDirectory *ed)
{
- gboolean is_zero;
-
g_return_if_fail (ed != NULL);
g_return_if_fail (ed->refcount > 0);
- is_zero = g_atomic_int_dec_and_test (&ed->refcount);
- if (is_zero)
+ if (--ed->refcount == 0)
{
cached_dir_remove_reference (ed->dir);
@@ -952,12 +948,11 @@ entry_directory_foreach_recursive (EntryDirectory *ed,
if (desktop_entry_get_type (entry) == ed->entry_type)
{
- gboolean ret;
- char *file_id;
- const char *basename;
+ gboolean ret;
+ char *file_id;
- basename = desktop_entry_get_basename (entry);
- g_string_append (relative_path, basename);
+ g_string_append (relative_path,
+ desktop_entry_get_basename (entry));
file_id = get_desktop_file_id_from_path (ed,
ed->entry_type,
@@ -1037,7 +1032,7 @@ entry_directory_get_flat_contents (EntryDirectory *ed,
DesktopEntry *entry = tmp->data;
const char *basename;
- basename = desktop_entry_get_path (entry);
+ basename = desktop_entry_get_basename (entry);
if (desktop_entries &&
desktop_entry_get_type (entry) == DESKTOP_ENTRY_DESKTOP)
@@ -1110,7 +1105,7 @@ entry_directory_list_ref (EntryDirectoryList *list)
g_return_val_if_fail (list != NULL, NULL);
g_return_val_if_fail (list->refcount > 0, NULL);
- g_atomic_int_inc (&list->refcount);
+ list->refcount += 1;
return list;
}
@@ -1118,13 +1113,11 @@ entry_directory_list_ref (EntryDirectoryList *list)
void
entry_directory_list_unref (EntryDirectoryList *list)
{
- gboolean is_zero;
-
g_return_if_fail (list != NULL);
g_return_if_fail (list->refcount > 0);
- is_zero = g_atomic_int_dec_and_test (&list->refcount);
- if (is_zero)
+ list->refcount -= 1;
+ if (list->refcount == 0)
{
g_list_foreach (list->dirs, (GFunc) entry_directory_unref, NULL);
g_list_free (list->dirs);
diff --git a/libmenu/gmenu-tree.c b/libmenu/gmenu-tree.c
index 091a719..9aa94c5 100644
--- a/libmenu/gmenu-tree.c
+++ b/libmenu/gmenu-tree.c
@@ -1242,12 +1242,8 @@ gmenu_tree_directory_make_path (GMenuTreeDirectory *directory,
append_directory_path (directory, path);
if (entry != NULL)
- {
- const char *basename;
-
- basename = desktop_entry_get_basename (entry->desktop_entry);
- g_string_append (path, basename);
- }
+ g_string_append (path,
+ desktop_entry_get_basename (entry->desktop_entry));
return g_string_free (path, FALSE);
}
@@ -1277,7 +1273,7 @@ gmenu_tree_entry_get_desktop_file_path (GMenuTreeEntry *entry)
const char *
gmenu_tree_entry_get_desktop_file_id (GMenuTreeEntry *entry)
{
- g_return_val_if_fail (entry != NULL, FALSE);
+ g_return_val_if_fail (entry != NULL, NULL);
return entry->desktop_file_id;
}
diff --git a/po/el.po b/po/el.po
index e3fcc56..6678cfb 100644
--- a/po/el.po
+++ b/po/el.po
@@ -10,16 +10,16 @@ msgstr ""
"Project-Id-Version: el\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-"
"menus&keywords=I18N+L10N&component=general\n"
-"POT-Creation-Date: 2013-02-19 22:31+0000\n"
-"PO-Revision-Date: 2013-02-24 10:21+0300\n"
+"POT-Creation-Date: 2013-12-18 20:58+0000\n"
+"PO-Revision-Date: 2013-12-23 08:45+0300\n"
"Last-Translator: Dimitris Spingos (Δημήτρης Σπίγγος) <dmtrs32@gmail.com>\n"
-"Language-Team: team@gnome.gr\n"
+"Language-Team: team@lists.gnome.gr\n"
"Language: el\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Virtaal 0.7.1\n"
+"X-Generator: Virtaal 0.7.0\n"
"X-Project-Style: gnome\n"
#: ../desktop-directories/AudioVideo.directory.in.h:1
@@ -117,7 +117,7 @@ msgstr "Διάφορα"
#: ../desktop-directories/X-GNOME-Utilities.directory.in.h:1
msgid "Utilities"
-msgstr "Βοηθήματα"
+msgstr "Βοηθητικά προγράμματα"
#: ../desktop-directories/X-GNOME-Utilities.directory.in.h:2
msgid "Small but useful GNOME tools"
diff --git a/po/fr.po b/po/fr.po
index 5721f91..e227f32 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -14,7 +14,7 @@ msgstr ""
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-"
"menus&keywords=I18N+L10N&component=general\n"
"POT-Creation-Date: 2013-02-20 09:33+0000\n"
-"PO-Revision-Date: 2013-02-20 21:14+0100\n"
+"PO-Revision-Date: 2013-10-23 16:35+0200\n"
"Last-Translator: Claude Paroz <claude@2xlibre.net>\n"
"Language-Team: GNOME French team <gnomefr@traduc.org>\n"
"Language: \n"
@@ -72,7 +72,7 @@ msgstr "Bureautique"
#: ../desktop-directories/Office.directory.in.h:2
msgid "Office Applications"
-msgstr "Autres applications"
+msgstr "Applications de bureautique"
#: ../desktop-directories/System-Tools.directory.in.h:1
msgid "System Tools"
diff --git a/po/ml.po b/po/ml.po
index 3ab08af..bdee38d 100644
--- a/po/ml.po
+++ b/po/ml.po
@@ -5,14 +5,15 @@
# Ani Peter <peter.ani@gmail.com>, 2006.
# Praveen|പ്രവീണ്‍ A|എ <pravi.a@gmail.com>, 2007,2008.
# Ani Peter <apeter@redhat.com>, 2007, 2012, 2013.
+# Akhilan <akhilkrishnans@gmail.com, 2013
msgid ""
msgstr ""
"Project-Id-Version: gnome-menus.master.ml\n"
"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-"
"menus&keywords=I18N+L10N&component=general\n"
-"POT-Creation-Date: 2013-03-18 10:33+0000\n"
-"PO-Revision-Date: 2013-03-25 19:17+0530\n"
-"Last-Translator: Ani Peter <peter.ani@gmail.com>\n"
+"POT-Creation-Date: 2013-10-23 14:43+0000\n"
+"PO-Revision-Date: 2013-11-03 14:28+0530\n"
+"Last-Translator: Akhilan <akhilkrishnans@gmail.com>\n"
"Language-Team: Malayalam <discuss@lists.smc.org.in>\n"
"Language: ml\n"
"MIME-Version: 1.0\n"
@@ -27,7 +28,7 @@ msgstr "ശബ്ദവും ചലച്ചിത്രവും"
#: ../desktop-directories/AudioVideo.directory.in.h:2
msgid "Multimedia menu"
-msgstr "മള്‍ട്ടീമീഡിയ മെനു"
+msgstr "മള്‍ട്ടീമീഡിയ ഐച്ഛികം"
#: ../desktop-directories/Development.directory.in.h:1
msgid "Programming"
@@ -95,7 +96,7 @@ msgstr "ഉപകരണങ്ങള്‍"
#: ../desktop-directories/Utility.directory.in.h:2
msgid "Desktop accessories"
-msgstr "പണിയിടോപകരണങ്ങള്‍"
+msgstr "പണിയിട ഉപകരണങ്ങള്‍"
#: ../desktop-directories/X-GNOME-Menu-Applications.directory.in.h:1
msgid "Applications"
diff --git a/util/test-menu-spec.c b/util/test-menu-spec.c
index c48509e..00ea252 100644
--- a/util/test-menu-spec.c
+++ b/util/test-menu-spec.c
@@ -207,8 +207,6 @@ main (int argc, char **argv)
GMenuTreeFlags flags;
GError *error = NULL;
- g_type_init ();
-
#if 0
/* See comment when defining _() at the top of this file. */
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);

View File

@ -3,13 +3,15 @@
Summary: A menu system for the GNOME project
Name: gnome-menus
Version: 3.10.1
Release: 1%{?dist}
Release: 2%{?dist}
License: LGPLv2+
Group: System Environment/Libraries
URL: http://www.gnome.org/
#VCS: git:git://git.gnome.org/gnome-menus
Source0: http://download.gnome.org/sources/gnome-menus/3.10/%{name}-%{version}.tar.xz
# Bumps to git master as of 2014-01-08, fixes an annoying crasher
Patch0: gnome-menus-3.10.1-git94ba6e23c0.patch
Requires: redhat-menus
BuildRequires: gamin-devel
BuildRequires: gawk
@ -38,6 +40,7 @@ writing applications that use the GNOME menu system.
%prep
%setup -q
%patch0 -p1 -b .git
%build
%configure --disable-static \
@ -75,6 +78,9 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%{_datadir}/gir-1.0/GMenu-3.0.gir
%changelog
* Wed Jan 08 2014 Adam Williamson <awilliam@redhat.com> - 3.10.1-2
- patch up to current git master (should fix annoying crashes)
* Tue Oct 29 2013 Richard Hughes <rhughes@redhat.com> - 3.10.1-1
- Update to 3.10.1