[polari] thumbnailer: Handle load failure



commit a4494a85b7d370774e100516e16f84d30418c97f
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Dec 16 14:13:05 2019 +0100

    thumbnailer: Handle load failure
    
    We don't want to create blank thumbnails for pages that fail to load
    (because the network goes down, or the host is behind a VPN etc.).
    Simply bail out early in that case.
    
    https://gitlab.gnome.org/GNOME/polari/merge_requests/139

 src/thumbnailer.js | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/src/thumbnailer.js b/src/thumbnailer.js
index 34eddd5..6948ae9 100644
--- a/src/thumbnailer.js
+++ b/src/thumbnailer.js
@@ -15,6 +15,7 @@ let PreviewWindow = GObject.registerClass({
     },
     Signals: {
         'snapshot-ready': {},
+        'snapshot-failed': {},
     },
 }, class PreviewWindow extends Gtk.Window {
     _init(params) {
@@ -35,6 +36,7 @@ let PreviewWindow = GObject.registerClass({
 
         this._view.connect('notify::is-loading',
             this._onLoadingChanged.bind(this));
+        this._view.connect('load-failed', () => this.emit('snapshot-failed'));
         this._view.load_uri(this.uri);
     }
 
@@ -60,6 +62,8 @@ let PreviewWindow = GObject.registerClass({
                     this._snapshot = this._view.get_snapshot_finish(res);
                 } catch (e) {
                     log(`Creating snapshot failed: ${e}`);
+                    this.emit('snapshot-failed');
+                    return;
                 }
                 this.emit('snapshot-ready');
             });
@@ -87,6 +91,7 @@ class App {
 
         window.realize();
         window.connect('snapshot-ready', this._onSnapshotReady.bind(this));
+        window.connect('snapshot-failed', () => window.destroy());
         window.connect('destroy', () => Gtk.main_quit());
 
         Gtk.main();


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