After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 172046 - Muliple MenuTree changed notifications per file change
Muliple MenuTree changed notifications per file change
Status: RESOLVED FIXED
Product: gnome-menus
Classification: Core
Component: libgnome-menu
git master
Other All
: High normal
: ---
Assigned To: gnome-menus dummy account
gnome-menus dummy account
Depends on:
Blocks:
 
 
Reported: 2005-03-29 23:41 UTC by Christian Neumair
Modified: 2010-10-06 13:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Verbose gnome-menu-editor session (150.83 KB, application/x-bzip)
2005-03-30 00:00 UTC, Christian Neumair
  Details
Compress GMenuTree monitor notifications (4.58 KB, patch)
2009-09-04 21:14 UTC, Owen Taylor
none Details | Review
Alternative patch (4.31 KB, patch)
2010-09-23 15:14 UTC, Vincent Untz
committed Details | Review

Description Christian Neumair 2005-03-29 23:41:53 UTC
Sometimes, two FAM event emissions with only a short period of time in between
lead to a situation in which my MenuTreeChangedFunc is called over and over.
I could reproduce this bug for a custom menu file I put under
~/.config/menus/applications-merged/gnome-menu-editor.menu with

mv ~/.config/menus/applications-merged/gnome-menu-editor.menu \
~/.config/menus/applications-merged/gnome-menu-editor-old.menu; \
sleep 0.5;
mv ~/.config/menus/applications-merged/gnome-menu-editor-old.menu \
~/.config/menus/applications-merged/gnome-menu-editor.menu
Comment 1 Christian Neumair 2005-03-29 23:47:45 UTC
Hrm it doesn't seem to be really reproducible using the above command; it works
at least always when creating a desktop file in ~/.local/share/applications and
shortly after creating or modifying
~/.config/menus/applications-merged/gnome-menu-editor.menu. Can I provide any
extra debug info?
MENU_VERBOSE wasn't verbose enough. At least it didn't tell me why the second,
third, nth callback was called; it just informed me that the first callback was
called because of the addition of a custom desktop file.
Comment 2 Christian Neumair 2005-03-30 00:00:19 UTC
Created attachment 39411 [details]
Verbose gnome-menu-editor session

I've attached a sample of a problematic gnome-menu-editor session with
MENU_VERBOSE enabled. Detailed information is provided in the tarball's README
file.
Comment 3 Christian Neumair 2005-03-30 10:03:57 UTC
Looks like that thing is NOT called forever. The problem is that it is called
for the CachedDir in question, foreach EntryDirectory, i.e. menu node. In
entry-directories.c, each EntryDirectory registers a EntryDirectoryChangedFunc
monitor and on CachedDir changes, each one is called. Therefore, if your menu
tree has N menus, the callback is called N times.
Comment 4 Christian Neumair 2005-03-30 10:30:34 UTC
This only seems to be relevant if the menu tree is instantly re-read after the
change monitors have been notified, as it is the case with gnome-menu-editor.
Comment 5 Mark McLoughlin 2005-04-04 14:30:28 UTC
Right, known issue - the monitoring stuff needs to be significantly re-worked.
See bug #160194.

Really, the way things are currently, the monitor callbacks should only queue an
idle handler. That's what the panel does too.
Comment 6 Owen Taylor 2009-09-04 21:14:08 UTC
Created attachment 142506 [details] [review]
Compress GMenuTree monitor notifications

Changes to a single file on disk could potentially cause changes to
many nodes in the menu tree. Since we make no attempt to determine
what actually changed versus potentially changed and, in any case,
don't provide any fine-grained indication of what node changed, we
need to compress our changes in order to avoid providing many
identical notifications.

Do this in the standard way by using an idle to defer the actual
work of notification. The idle priorities for this and for the
idle used in menu-monitor.c are adjusted to give maximum opportunity
for compression.
Comment 7 Owen Taylor 2009-09-04 21:26:57 UTC
I think that the original confusion here about the circumstances where this occurs probably has to do with the nature of the way that notifications occur. When notified of a change, GMenuTree deletes everything and that removes the monitors. And they aren't created again until the trees are refetched.

So, as long as you don't *do* anything in your notification callbacks, they look like they are compressed. It's not a very useful form of compression, however.

Other note is that the reason I did the compression in menu-layout.c rather than in gmenu-tree.c, is that menu-layout.c is where the duplicates are generated - where we take a notification on a leaf directory and turn it into an undifferentiated notification on the root directory
Comment 8 Vincent Untz 2010-09-23 15:14:45 UTC
Created attachment 170924 [details] [review]
Alternative patch

Hrm, I hadn't see Owen's patch, so I wrote this today, which is quite similar (except that it also compresses notifications at the CachedDir level). I'll commit this after the freeze.