[gnome-music/wip/mschraal/correct-idle-add-usage] playlistview: Correct idle_add use



commit 5c0c4a11909d76a24abf450725ee231492183ab4
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu May 2 16:24:44 2019 +0200

    playlistview: Correct idle_add use
    
    Using GLib.idle_add comes with constraints, which were not cleanly followed
    in the current code.
    
    Remove one unneeded use of idle_add and explicitly return
    GLib.SOURCE_REMOVE in another instance.

 gnomemusic/views/playlistview.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/views/playlistview.py b/gnomemusic/views/playlistview.py
index bb43d840..1e6742ba 100644
--- a/gnomemusic/views/playlistview.py
+++ b/gnomemusic/views/playlistview.py
@@ -347,11 +347,11 @@ class PlaylistView(BaseView):
         """
         def activate_song():
             if self._song_drag['active']:
-                return
+                return GLib.SOURCE_REMOVE
 
             if self._star_handler.star_renderer_click:
                 self._star_handler.star_renderer_click = False
-                return
+                return GLib.SOURCE_REMOVE
 
             _iter = None
             if path:
@@ -361,6 +361,8 @@ class PlaylistView(BaseView):
                 PlayerPlaylist.Type.PLAYLIST, playlist_id, self.model, _iter)
             self.player.play()
 
+            return GLib.SOURCE_REMOVE
+
         # 'row-activated' signal is emitted before 'drag-begin' signal.
         # Need to wait to check if drag and drop operation is active.
         GLib.idle_add(activate_song)
@@ -479,7 +481,7 @@ class PlaylistView(BaseView):
             if (str(playlist_id) == playlist.get_id()
                     and self._is_current_playlist(playlist)):
                 self._star_handler.star_renderer_click = False
-                GLib.idle_add(self._on_playlist_activated, self._sidebar, row)
+                self._on_playlist_activated(self._sidebar, row)
                 break
 
     @log


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]