[meld/pathlabel: 72/73] recent: Handle bad comparison metadata cases




commit 15e8fecee1a2bf65c2e29f4f1cbc2c6e0e24cd68
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Aug 15 10:20:43 2021 +1000

    recent: Handle bad comparison metadata cases
    
    This happens most often when there is missing data in the comparison,
    such as when we have empty comparisons with no location. While we can
    try to make the individual comparison types handle this better, it's
    also sensible to make the recent handling just ignore this problem,
    since it can't possibly record a sensible recent document.

 meld/recent.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/meld/recent.py b/meld/recent.py
index 3c361818..c28566bc 100644
--- a/meld/recent.py
+++ b/meld/recent.py
@@ -26,6 +26,7 @@ infrastructure that that's actually what we opened.
 
 import configparser
 import enum
+import logging
 import os
 import sys
 import tempfile
@@ -36,6 +37,8 @@ from gi.repository import Gio, GLib, Gtk
 import meld.misc
 from meld.conf import _
 
+log = logging.getLogger(__name__)
+
 
 class RecentType(enum.Enum):
     File = "File"
@@ -73,7 +76,11 @@ class RecentFiles:
         The passed flags are currently ignored. In the future these are to be
         used for extra initialisation not captured by the tab itself.
         """
-        recent_type, gfiles = tab.get_comparison()
+        try:
+            recent_type, gfiles = tab.get_comparison()
+        except Exception:
+            log.warning(f'Failed to get recent comparison data for {tab}')
+            return
 
         # While Meld handles comparisons including None, recording these as
         # recently-used comparisons just isn't that sane.


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