[gnome-shell] shell/screenshot: Remove unnecessary NULL check
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] shell/screenshot: Remove unnecessary NULL check
- Date: Tue, 24 Mar 2020 11:35:24 +0000 (UTC)
commit 1bccbe7f11c0523c375b2404e2d489e8bfc044a2
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Mar 24 07:10:27 2020 +0100
shell/screenshot: Remove unnecessary NULL check
Since commit be5f5ec9d40, the output stream is created externally and
expected to be non-NULL, so the check is now pointless (in particular
*after* calling g_object_ref() on the stream).
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1123
src/shell-screenshot.c | 46 +++++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 29 deletions(-)
---
diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c
index 14da0cad17..4cc65bd771 100644
--- a/src/shell-screenshot.c
+++ b/src/shell-screenshot.c
@@ -88,10 +88,11 @@ write_screenshot_thread (GTask *result,
GCancellable *cancellable)
{
cairo_status_t status;
- GOutputStream *stream;
ShellScreenshot *screenshot = SHELL_SCREENSHOT (object);
ShellScreenshotPrivate *priv;
- char *creation_time;
+ g_autoptr (GOutputStream) stream = NULL;
+ g_autoptr(GdkPixbuf) pixbuf = NULL;
+ g_autofree char *creation_time = NULL;
g_assert (screenshot != NULL);
@@ -99,37 +100,24 @@ write_screenshot_thread (GTask *result,
stream = g_object_ref (priv->stream);
- if (stream == NULL)
- status = CAIRO_STATUS_FILE_NOT_FOUND;
- else
- {
- GdkPixbuf *pixbuf;
-
- pixbuf = gdk_pixbuf_get_from_surface (priv->image,
- 0, 0,
- cairo_image_surface_get_width (priv->image),
- cairo_image_surface_get_height (priv->image));
- creation_time = g_date_time_format (priv->datetime, "%c");
-
- if (!creation_time)
- creation_time = g_date_time_format (priv->datetime, "%FT%T%z");
-
- if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL,
- "tEXt::Software", "gnome-screenshot",
- "tEXt::Creation Time", creation_time,
- NULL))
- status = CAIRO_STATUS_SUCCESS;
- else
- status = CAIRO_STATUS_WRITE_ERROR;
+ pixbuf = gdk_pixbuf_get_from_surface (priv->image,
+ 0, 0,
+ cairo_image_surface_get_width (priv->image),
+ cairo_image_surface_get_height (priv->image));
+ creation_time = g_date_time_format (priv->datetime, "%c");
- g_object_unref (pixbuf);
- g_free (creation_time);
- }
+ if (!creation_time)
+ creation_time = g_date_time_format (priv->datetime, "%FT%T%z");
+ if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL,
+ "tEXt::Software", "gnome-screenshot",
+ "tEXt::Creation Time", creation_time,
+ NULL))
+ status = CAIRO_STATUS_SUCCESS;
+ else
+ status = CAIRO_STATUS_WRITE_ERROR;
g_task_return_boolean (result, status == CAIRO_STATUS_SUCCESS);
-
- g_clear_object (&stream);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]