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

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