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 737798 - Toggling media-keys inactive/active results in duplicate key commands
Toggling media-keys inactive/active results in duplicate key commands
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: media-keys
3.14.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2014-10-02 19:11 UTC by Paul W. Frields
Modified: 2014-10-17 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
media-keys: Don't leak the key grabber proxy across plugin restarts (1.05 KB, patch)
2014-10-03 16:14 UTC, Rui Matos
accepted-commit_now Details | Review
media-keys: Don't leak the screencast proxy across shell restarts (917 bytes, patch)
2014-10-03 16:14 UTC, Rui Matos
accepted-commit_now Details | Review
media-keys: Don't leak the idle GSource across plugin restarts (1.40 KB, patch)
2014-10-03 16:14 UTC, Rui Matos
needs-work Details | Review
media-keys: Don't leak the shell proxy across plugin restarts (1.26 KB, patch)
2014-10-03 16:14 UTC, Rui Matos
needs-work Details | Review
media-keys: Don't leak the logind proxy (1013 bytes, patch)
2014-10-03 16:14 UTC, Rui Matos
accepted-commit_now Details | Review
media-keys: Don't leak the idle GSource across plugin restarts (1.46 KB, patch)
2014-10-16 17:29 UTC, Rui Matos
none Details | Review

Description Paul W. Frields 2014-10-02 19:11:26 UTC
Fedora 21 x86_64 + updates, including gnome-settings-daemon-3.14.0-1.fc21.x86_64

This is what I did to reproduce:
1. Assign a shortcut key to open a terminal -- I use Ctrl+Alt+T for this.  Hit Ctrl+Alt+T to test.
2. gsettings set org.gnome.settings-daemon.plugins.media-keys active false
3. gsettings set org.gnome.settings-daemon.plugins.media-keys active true
4. Hit Ctrl+Alt+T ==> 2 new terminal windows open.
5. For fun, repeat 2-4 and you'll get 3 new terminals open, and so on.
Comment 1 Rui Matos 2014-10-03 16:14:17 UTC
Created attachment 287681 [details] [review]
media-keys: Don't leak the key grabber proxy across plugin restarts

In particular, this fixes multiple calls to on_accelerator_activated()
after stopping and starting the plugin.
Comment 2 Rui Matos 2014-10-03 16:14:22 UTC
Created attachment 287682 [details] [review]
media-keys: Don't leak the screencast proxy across shell restarts
Comment 3 Rui Matos 2014-10-03 16:14:27 UTC
Created attachment 287683 [details] [review]
media-keys: Don't leak the idle GSource across plugin restarts
Comment 4 Rui Matos 2014-10-03 16:14:32 UTC
Created attachment 287684 [details] [review]
media-keys: Don't leak the shell proxy across plugin restarts
Comment 5 Rui Matos 2014-10-03 16:14:38 UTC
Created attachment 287685 [details] [review]
media-keys: Don't leak the logind proxy
Comment 6 Bastien Nocera 2014-10-16 11:00:24 UTC
Review of attachment 287681 [details] [review]:

Yep.
Comment 7 Bastien Nocera 2014-10-16 11:00:46 UTC
Review of attachment 287682 [details] [review]:

Yep.
Comment 8 Bastien Nocera 2014-10-16 11:01:21 UTC
Review of attachment 287683 [details] [review]:

::: plugins/media-keys/gsd-media-keys-manager.c
@@ +2415,3 @@
 
+        if (priv->start_idle_id != 0)
+                g_source_remove (priv->start_idle_id);

missing setting the start_idle_id to 0 too.
Comment 9 Bastien Nocera 2014-10-16 11:07:06 UTC
Review of attachment 287684 [details] [review]:

Instead of doing that, we should just make finalize call _stop().

That would avoid the code duplication.
Comment 10 Bastien Nocera 2014-10-16 11:07:24 UTC
Review of attachment 287685 [details] [review]:

Looks good.
Comment 11 Rui Matos 2014-10-16 17:26:49 UTC
(In reply to comment #9)
> Review of attachment 287684 [details] [review]:
> 
> Instead of doing that, we should just make finalize call _stop().

We could though I see some plugins doing it while others don't. But see below

> That would avoid the code duplication.

Which duplication? The way I see it, the rule is pretty simple: whatever gets instanced in _start() must be unrefed in _stop() and whatever gets instanced in _init() must be unrefed in _finalize(). That's what I did here.
Comment 12 Rui Matos 2014-10-16 17:29:02 UTC
Created attachment 288703 [details] [review]
media-keys: Don't leak the idle GSource across plugin restarts

--

(In reply to comment #8)
> missing setting the start_idle_id to 0 too.

Doh, fixed
Comment 13 Bastien Nocera 2014-10-17 13:33:23 UTC
(In reply to comment #11)
> (In reply to comment #9)
> > Review of attachment 287684 [details] [review] [details]:
> > 
> > Instead of doing that, we should just make finalize call _stop().
> 
> We could though I see some plugins doing it while others don't. But see below
> 
> > That would avoid the code duplication.
> 
> Which duplication? The way I see it, the rule is pretty simple: whatever gets
> instanced in _start() must be unrefed in _stop() and whatever gets instanced in
> _init() must be unrefed in _finalize(). That's what I did here.

Right. But you need to do everything that stop() does in finalize, in case stop() wasn't called before finalize().
Comment 14 Rui Matos 2014-10-17 16:09:19 UTC
Pushed everything here and patches to call stop on finalize for all plugins that were missing it (including fixing some cases that weren't cleaning up completely on stop).