Blame SOURCES/gnome-documents-dont-attempt-to-load-collections.patch

b5c23e
From b94e146d30e112ba2b86946f648fb57a2f91293c Mon Sep 17 00:00:00 2001
b5c23e
From: Debarshi Ray <debarshir@gnome.org>
b5c23e
Date: Fri, 24 Aug 2018 14:39:57 +0200
b5c23e
Subject: [PATCH 1/2] documents: Error out if an attempt was made to load a
b5c23e
 local collection
b5c23e
b5c23e
Local collections don't have an URI (ie. this.uriToLoad is empty).
b5c23e
Since commit 70381b8723dc491f, whenever a single item is selected, it
b5c23e
is loaded to check if it can be printed. Doing this load for local
b5c23e
collections with an empty URI leads to an assertion inside the PDF
b5c23e
loader.
b5c23e
b5c23e
Attempting to load a collection is a programming error. Ideally, that
b5c23e
would lead to an exception being thrown, but since the base DocCommon
b5c23e
class passes a GError to the callback, it is better to stick to that
b5c23e
for consistency.
b5c23e
b5c23e
This should have been included in commit 87a04ee157a84795, which
b5c23e
introduced the same check in the base class.
b5c23e
b5c23e
https://gitlab.gnome.org/GNOME/gnome-documents/issues/7
b5c23e
---
b5c23e
 src/documents.js | 14 ++++++++++++++
b5c23e
 1 file changed, 14 insertions(+)
b5c23e
b5c23e
diff --git a/src/documents.js b/src/documents.js
b5c23e
index 823cfabd74c3..40462ac99120 100644
b5c23e
--- a/src/documents.js
b5c23e
+++ b/src/documents.js
b5c23e
@@ -928,6 +928,20 @@ var LocalDocument = new Lang.Class({
b5c23e
 
b5c23e
     load: function(passwd, cancellable, callback) {
b5c23e
         Utils.debug('Loading ' + this.__name__ + ' ' + this.id);
b5c23e
+
b5c23e
+        if (this.collection) {
b5c23e
+            Mainloop.idle_add(Lang.bind(this,
b5c23e
+                function() {
b5c23e
+                    let error = new GLib.Error(Gio.IOErrorEnum,
b5c23e
+                                               Gio.IOErrorEnum.NOT_SUPPORTED,
b5c23e
+                                               "Collections can't be loaded");
b5c23e
+                    callback(this, null, error);
b5c23e
+                    return GLib.SOURCE_REMOVE;
b5c23e
+                }));
b5c23e
+
b5c23e
+            return;
b5c23e
+        }
b5c23e
+
b5c23e
         this.loadLocal(passwd, cancellable, callback);
b5c23e
     },
b5c23e
 
b5c23e
-- 
b5c23e
2.14.4
b5c23e
b5c23e
b5c23e
From 7dd613b087bd1afef336166e7662e68d8b32e997 Mon Sep 17 00:00:00 2001
b5c23e
From: Debarshi Ray <debarshir@gnome.org>
b5c23e
Date: Fri, 24 Aug 2018 15:15:03 +0200
b5c23e
Subject: [PATCH 2/2] selections: Don't attempt to load collections
b5c23e
b5c23e
Attempting to load a collection is a programming error. Currently, that
b5c23e
leads to a GError and a NULL EvDocument pointer being passed to the
b5c23e
callback, which ends up getting handled properly. It's better to avoid
b5c23e
even attempting the load, in case such programming errors are dealt
b5c23e
with more strictly in the future.
b5c23e
b5c23e
Fallout from 70381b8723dc491f3267fc804178b9d64beedd2d
b5c23e
b5c23e
https://gitlab.gnome.org/GNOME/gnome-documents/issues/7
b5c23e
---
b5c23e
 src/selections.js | 12 +++++++-----
b5c23e
 1 file changed, 7 insertions(+), 5 deletions(-)
b5c23e
b5c23e
diff --git a/src/selections.js b/src/selections.js
b5c23e
index b18132116a09..bf45d23bfe57 100644
b5c23e
--- a/src/selections.js
b5c23e
+++ b/src/selections.js
b5c23e
@@ -969,11 +969,13 @@ var SelectionToolbar = new Lang.Class({
b5c23e
 
b5c23e
         if (selection.length == 1) {
b5c23e
             let doc = Application.documentManager.getItemById(selection[0]);
b5c23e
-            doc.load(null, null, Lang.bind(this,
b5c23e
-                function(doc, docModel, error) {
b5c23e
-                    showPrint = doc.canPrint(docModel);
b5c23e
-                    this._toolbarPrint.set_sensitive(showPrint);
b5c23e
-                }));
b5c23e
+            if (!doc.collection) {
b5c23e
+                doc.load(null, null, Lang.bind(this,
b5c23e
+                    function(doc, docModel, error) {
b5c23e
+                        showPrint = doc.canPrint(docModel);
b5c23e
+                        this._toolbarPrint.set_sensitive(showPrint);
b5c23e
+                    }));
b5c23e
+            }
b5c23e
         }
b5c23e
 
b5c23e
         if (selection.length > 1)
b5c23e
-- 
b5c23e
2.14.4
b5c23e