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 587548 - Duplicate firefox in search results
Duplicate firefox in search results
Status: RESOLVED DUPLICATE of bug 587818
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: High critical
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2009-07-01 18:02 UTC by Owen Taylor
Modified: 2009-07-07 23:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug 587548 - Whitelist nodisplay desktop files to be included (2.87 KB, patch)
2009-07-03 19:16 UTC, Colin Walters
none Details | Review
Don't include NoDisplay items, except for window identification (1.36 KB, patch)
2009-07-04 14:07 UTC, Owen Taylor
committed Details | Review

Description Owen Taylor 2009-07-01 18:02:11 UTC
When I type 'firefox', I get two entries in the search results. Is this from includiong NoDisplay desktop files?
Comment 1 Colin Walters 2009-07-02 07:34:38 UTC
Yes.  In particular something is writing out ~/.local/share/applications/preferred-web-browser.desktop which is just:

--- /usr/share/applications/mozilla-firefox.desktop	2009-06-11 20:39:15.000000000 -0400
+++ /home/walters/.local/share/applications/preferred-web-browser.desktop	2008-04-21 12:04:00.000000000 -0400
@@ -72,3 +72,5 @@
 StartupNotify=true
 X-Desktop-File-Install-Version=0.15
 Categories=Network;WebBrowser;
+X-Panel-Monitor=true
+NoDisplay=true


We might be able to look for X-Panel-Monitor and skip?
Comment 2 Milan Bouchet-Valat 2009-07-02 12:19:13 UTC
An how about fixing the program that is creating this file? If we consider that one .desktop file <=> one distinct program, it should not create files for this use, but rather create a symlink to the actual .desktop file for Firefox. Than we could easily find it's a duplicate.

This approach is better for the said program too, since the command to start the browser, its description *and translations* will be updated with firefox, which is not the case when merely re-creating the file.
Comment 3 Colin Walters 2009-07-03 19:16:39 UTC
Created attachment 137808 [details] [review]
Bug 587548 - Whitelist nodisplay desktop files to be included

Currently we only want to pick up a few targeted .desktop files,
namely Evince and Nautilus.  In the future maybe we'll change
the Evince .desktop but continue to special-case nautilus.
Comment 4 Owen Taylor 2009-07-04 14:06:45 UTC
+/* This baroque code avoids writable memory; see dsohowto.pdf */
+static const char *nodisplay_whitelist = {
+  "evince.desktop"
+  "gnome-nautilus.desktop"
+};
+
+static const size_t nodisplay_whitelist_indices[] = {
+    0,
+    sizeof (nodisplay_whitelist[0])
+};
+
+static const char *
+nodisplay_index (int idx)
+{
+  return nodisplay_whitelist + nodisplay_whitelist_indices[idx];
+}

I don't see anything exactly like this in the DSO-howto, and I don't see how it works.

 A) Your strings aren't null terminated, so when you find one, it won't be usable in strcmp() easily fixed by adding \0

 B) sizeof (nodisplay_whitelist[0]) is 1, right? Not easily fixed. The techniques in the DSO howto are all either complex or ugly.

We're not actually a shared library that's *shared*, and I just don't see introducing complexity to save two relocations.

So, why did your patch work? I think it's because it didn't add the NoDisplay entries (any of them) to the cache, but it does include them (all of them) when doing shell_app_system_lookup_basename(). 

I'll attach a very, very stripped down version of your patch that seems to work as a fix for now.
Comment 5 Owen Taylor 2009-07-04 14:07:11 UTC
Created attachment 137833 [details] [review]
Don't include NoDisplay items, except for window identification

Searching across NoDisplay desktop items can produce weird
results to the user (including duplicates, and items that
aren't really applications at all.) So, don't include them
normally.

But continue including NoDisplay items when we look up the
desktop file for a window, since we want to catch applications
like Evince and Nautilus which are otherwise NoDisplay.
Comment 6 Colin Walters 2009-07-04 15:59:14 UTC
Ah yes, they should have been null terminated.  Well, it avoids writable memory, but yeah not a big deal.

Your patch is certainly far simpler and makes sense to me.
Comment 7 Owen Taylor 2009-07-07 11:18:42 UTC
I pushed the patch, but I'll leave this open until we get all the issues here fixed - see bug 587818 - in case we need to do something different here.
Comment 8 Colin Walters 2009-07-07 23:43:39 UTC

*** This bug has been marked as a duplicate of 587818 ***