[gnome-shell] screenshot: Return error when stream creation fails
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] screenshot: Return error when stream creation fails
- Date: Tue, 24 Mar 2020 11:35:14 +0000 (UTC)
commit eb51942a051f18f5993914968fcefb00a56c3625
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Mar 24 07:44:31 2020 +0100
screenshot: Return error when stream creation fails
The Shell.Screenshot API expects valid output streams for writing the
completed screenshot, not NULL.
Handle this properly by returning an error instead of passing it on
to the screenshot.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1123
js/ui/screenshot.js | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index 09f5c5109f..78afc4ae47 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -84,7 +84,7 @@ var ScreenshotService = class {
}
}
- _createStream(filename) {
+ _createStream(filename, invocation) {
if (filename == '')
return [Gio.MemoryOutputStream.new_resizable(), null];
@@ -94,6 +94,7 @@ var ScreenshotService = class {
let stream = file.replace(null, false, Gio.FileCreateFlags.NONE, null);
return [stream, file];
} catch (e) {
+ invocation.return_value(GLib.Variant.new('(bs)', [false, '']));
return [null, null];
}
}
@@ -104,10 +105,11 @@ var ScreenshotService = class {
return [stream, file];
} catch (e) {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS))
- return [null, null];
+ break;
}
}
+ invocation.return_value(GLib.Variant.new('(bs)', [false, '']));
return [null, null];
}
@@ -169,7 +171,9 @@ var ScreenshotService = class {
if (!screenshot)
return;
- let [stream, file] = this._createStream(filename);
+ let [stream, file] = this._createStream(filename, invocation);
+ if (!stream)
+ return;
screenshot.screenshot_area(x, y, width, height, stream,
(o, res) => {
@@ -190,7 +194,9 @@ var ScreenshotService = class {
if (!screenshot)
return;
- let [stream, file] = this._createStream(filename);
+ let [stream, file] = this._createStream(filename, invocation);
+ if (!stream)
+ return;
screenshot.screenshot_window(includeFrame, includeCursor, stream,
(o, res) => {
@@ -211,7 +217,9 @@ var ScreenshotService = class {
if (!screenshot)
return;
- let [stream, file] = this._createStream(filename);
+ let [stream, file] = this._createStream(filename, invocation);
+ if (!stream)
+ return;
screenshot.screenshot(includeCursor, stream,
(o, res) => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]