Commit 8521099a authored by Cosimo Cecchi's avatar Cosimo Cecchi

flash: make sure to keep a self reference while fading out

This way we can unref the flash object immediately instead of waiting
after the mainloop has quit.
parent 073354cf
......@@ -165,8 +165,8 @@ cheese_flash_opacity_fade (gpointer data)
static gboolean
cheese_flash_start_fade (gpointer data)
{
CheeseFlashPrivate *flash_priv = CHEESE_FLASH_GET_PRIVATE (CHEESE_FLASH (data));
CheeseFlash *self = data;
CheeseFlashPrivate *flash_priv = CHEESE_FLASH_GET_PRIVATE (self);
GtkWindow *flash_window = flash_priv->window;
/* If the screen is non-composited, just hide and finish up */
......@@ -176,7 +176,11 @@ cheese_flash_start_fade (gpointer data)
return FALSE;
}
flash_priv->fade_timeout_tag = g_timeout_add (1000.0 / FLASH_ANIMATION_RATE, cheese_flash_opacity_fade, data);
flash_priv->fade_timeout_tag =
g_timeout_add_full (G_PRIORITY_DEFAULT,
1000.0 / FLASH_ANIMATION_RATE,
cheese_flash_opacity_fade,
g_object_ref (self), g_object_unref);
return FALSE;
}
......@@ -197,7 +201,11 @@ cheese_flash_fire (CheeseFlash *flash,
gtk_window_set_opacity (flash_window, 0.99);
gtk_widget_show_all (GTK_WIDGET (flash_window));
flash_priv->flash_timeout_tag = g_timeout_add (FLASH_DURATION, cheese_flash_start_fade, (gpointer) flash);
flash_priv->flash_timeout_tag =
g_timeout_add_full (G_PRIORITY_DEFAULT,
FLASH_DURATION,
cheese_flash_start_fade,
g_object_ref (flash), g_object_unref);
}
CheeseFlash *
......
......@@ -507,6 +507,8 @@ finish_prepare_screenshot (GdkRectangle *rectangle)
cheese_flash_fire (flash, &rect);
play_sound_effect (window);
g_object_unref (flash);
if (screenshot_config->copy_to_clipboard)
{
screenshot_save_to_clipboard ();
......@@ -721,7 +723,6 @@ main (int argc, char *argv[])
gtk_main ();
g_clear_object (&flash);
g_clear_object (&connection);
return EXIT_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment