shell/screenshot: Check preconditions of public API
It's good practice to guard public API against programmer errors, so add the usual g_return*_if_fail() calls. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1123
This commit is contained in:
parent
eb51942a05
commit
b4162afa65
@ -479,10 +479,15 @@ shell_screenshot_screenshot (ShellScreenshot *screenshot,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ShellScreenshotPrivate *priv = screenshot->priv;
|
||||
ShellScreenshotPrivate *priv;
|
||||
gboolean use_paint_signal = FALSE;
|
||||
GTask *result;
|
||||
|
||||
g_return_if_fail (SHELL_IS_SCREENSHOT (screenshot));
|
||||
g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
|
||||
|
||||
priv = screenshot->priv;
|
||||
|
||||
if (priv->stream != NULL) {
|
||||
if (callback)
|
||||
g_task_report_new_error (screenshot,
|
||||
@ -549,6 +554,8 @@ shell_screenshot_screenshot_finish (ShellScreenshot *screenshot,
|
||||
cairo_rectangle_int_t **area,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (SHELL_IS_SCREENSHOT (screenshot), FALSE);
|
||||
g_return_val_if_fail (G_IS_TASK (result), FALSE);
|
||||
g_return_val_if_fail (g_async_result_is_tagged (result,
|
||||
shell_screenshot_screenshot),
|
||||
FALSE);
|
||||
@ -582,9 +589,14 @@ shell_screenshot_screenshot_area (ShellScreenshot *screenshot,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
ShellScreenshotPrivate *priv = screenshot->priv;
|
||||
ShellScreenshotPrivate *priv;
|
||||
GTask *result;
|
||||
|
||||
g_return_if_fail (SHELL_IS_SCREENSHOT (screenshot));
|
||||
g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
|
||||
|
||||
priv = screenshot->priv;
|
||||
|
||||
if (priv->stream != NULL) {
|
||||
if (callback)
|
||||
g_task_report_new_error (screenshot,
|
||||
@ -635,6 +647,8 @@ shell_screenshot_screenshot_area_finish (ShellScreenshot *screenshot,
|
||||
cairo_rectangle_int_t **area,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (SHELL_IS_SCREENSHOT (screenshot), FALSE);
|
||||
g_return_val_if_fail (G_IS_TASK (result), FALSE);
|
||||
g_return_val_if_fail (g_async_result_is_tagged (result,
|
||||
shell_screenshot_screenshot_area),
|
||||
FALSE);
|
||||
@ -663,12 +677,19 @@ shell_screenshot_screenshot_window (ShellScreenshot *screenshot,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ShellScreenshotPrivate *priv = screenshot->priv;
|
||||
MetaDisplay *display = shell_global_get_display (priv->global);
|
||||
ShellScreenshotPrivate *priv;
|
||||
MetaDisplay *display;
|
||||
ClutterActor *stage;
|
||||
MetaWindow *window = meta_display_get_focus_window (display);
|
||||
MetaWindow *window;
|
||||
GTask *result;
|
||||
|
||||
g_return_if_fail (SHELL_IS_SCREENSHOT (screenshot));
|
||||
g_return_if_fail (G_IS_OUTPUT_STREAM (stream));
|
||||
|
||||
priv = screenshot->priv;
|
||||
display = shell_global_get_display (priv->global);
|
||||
window = meta_display_get_focus_window (display);
|
||||
|
||||
if (priv->stream != NULL || !window) {
|
||||
if (callback)
|
||||
g_task_report_new_error (screenshot,
|
||||
@ -718,6 +739,8 @@ shell_screenshot_screenshot_window_finish (ShellScreenshot *screenshot,
|
||||
cairo_rectangle_int_t **area,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (SHELL_IS_SCREENSHOT (screenshot), FALSE);
|
||||
g_return_val_if_fail (G_IS_TASK (result), FALSE);
|
||||
g_return_val_if_fail (g_async_result_is_tagged (result,
|
||||
shell_screenshot_screenshot_window),
|
||||
FALSE);
|
||||
@ -742,19 +765,24 @@ shell_screenshot_pick_color (ShellScreenshot *screenshot,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ShellScreenshotPrivate *priv = screenshot->priv;
|
||||
MetaDisplay *display = shell_global_get_display (priv->global);
|
||||
ShellScreenshotPrivate *priv;
|
||||
MetaDisplay *display;
|
||||
ClutterActor *stage;
|
||||
GTask *result;
|
||||
|
||||
g_return_if_fail (SHELL_IS_SCREENSHOT (screenshot));
|
||||
|
||||
result = g_task_new (screenshot, NULL, callback, user_data);
|
||||
g_task_set_source_tag (result, shell_screenshot_pick_color);
|
||||
|
||||
priv = screenshot->priv;
|
||||
|
||||
priv->screenshot_area.x = x;
|
||||
priv->screenshot_area.y = y;
|
||||
priv->screenshot_area.width = 1;
|
||||
priv->screenshot_area.height = 1;
|
||||
|
||||
display = shell_global_get_display (priv->global);
|
||||
stage = CLUTTER_ACTOR (shell_global_get_stage (priv->global));
|
||||
|
||||
meta_disable_unredirect_for_display (display);
|
||||
@ -795,8 +823,11 @@ shell_screenshot_pick_color_finish (ShellScreenshot *screenshot,
|
||||
ClutterColor *color,
|
||||
GError **error)
|
||||
{
|
||||
ShellScreenshotPrivate *priv = screenshot->priv;
|
||||
ShellScreenshotPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (SHELL_IS_SCREENSHOT (screenshot), FALSE);
|
||||
g_return_val_if_fail (G_IS_TASK (result), FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
g_return_val_if_fail (g_async_result_is_tagged (result,
|
||||
shell_screenshot_pick_color),
|
||||
FALSE);
|
||||
@ -804,6 +835,8 @@ shell_screenshot_pick_color_finish (ShellScreenshot *screenshot,
|
||||
if (!g_task_propagate_boolean (G_TASK (result), error))
|
||||
return FALSE;
|
||||
|
||||
priv = screenshot->priv;
|
||||
|
||||
/* protect against mutter changing the format used for stage captures */
|
||||
g_assert (cairo_image_surface_get_format (priv->image) == CAIRO_FORMAT_ARGB32);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user