[polari] pasteManager: Fix warning when query_info() fails



commit a690896989d4695f04a1be752e6193e3c0123bd1
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Mar 15 17:59:55 2017 +0100

    pasteManager: Fix warning when query_info() fails
    
    The error path uses a local variable that's only defined in the
    caller, whoops. So just allow the exception to bubble up and
    handle the error there.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780113

 src/pasteManager.js |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/src/pasteManager.js b/src/pasteManager.js
index 7478055..530528d 100644
--- a/src/pasteManager.js
+++ b/src/pasteManager.js
@@ -174,13 +174,17 @@ const DropTargetIface = new Lang.Interface({
 
             // TODO: handle multiple files ...
             let file = Gio.File.new_for_uri(uris[0]);
-            this._lookupFileInfo(file, Lang.bind(this,
-                function(targetType) {
-                    let canHandle = targetType != 0;
-                    if (canHandle)
-                        this.emit('file-dropped', file);
-                    Gtk.drag_finish(context, canHandle, false, time);
-                }));
+            try {
+                this._lookupFileInfo(file, Lang.bind(this,
+                    function(targetType) {
+                        let canHandle = targetType != 0;
+                        if (canHandle)
+                            this.emit('file-dropped', file);
+                        Gtk.drag_finish(context, canHandle, false, time);
+                    }));
+            } catch(e) {
+                Gtk.drag_finish(context, false, false, time);
+            }
         } else {
             let success = false;
             switch(info) {
@@ -203,14 +207,7 @@ const DropTargetIface = new Lang.Interface({
                               GLib.PRIORITY_DEFAULT,
                               null, Lang.bind(this,
             function(f, res) {
-                let fileInfo = null;
-                try {
-                    fileInfo = file.query_info_finish(res);
-                } catch(e) {
-                    callback(0);
-                    Gtk.drag_finish(context, false, false, time);
-                }
-
+                let fileInfo = file.query_info_finish(res);
                 let contentType = fileInfo.get_content_type();
                 callback(_getTargetForContentType(contentType));
             }))


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