[gnome-music/wip/mschraal/coremodel-playlist-date-sort-crash] coremodel: Fix playlist sorting crash




commit 4bee96c039ac5369a678242fdd092bdbb9c0aa65
Author: Marinus Schraal <mschraal gnome org>
Date:   Mon Oct 12 21:07:21 2020 +0200

    coremodel: Fix playlist sorting crash
    
    Due to a bug in the grilo-plugins 0.3.12 Tracker3 plugin, playlists do
    not have a creation date set.
    
    Ignore the missing creation date while sorting to avoid the crash.
    
    Fixes: #417

 gnomemusic/coremodel.py | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 7d8f8173e..77e2bc762 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -183,6 +183,10 @@ class CoreModel(GObject.GObject):
         if playlist_b.props.is_smart:
             return 1
 
+        if (playlist_a.props.creation_date is None
+                or playlist_b.props.creation_date is None):
+            return 0
+
         # cannot use GLib.DateTime.compare
         # https://gitlab.gnome.org/GNOME/pygobject/issues/334
         # newest first


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