gtk/dialogs: Destroy the window promptly on finish async function
Some bindings (GJS!) could add temporary references to the GAsyncResult argument that we return, and thus to the GTask, which may cause the dialog not to close when the finish function is called (but at garbage collection instead!). To prevent this, just manually destroy the window (by removing the task data), so that we are not bound to the GTask lifetime anymore. Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5741
This commit is contained in:
committed by
Matthias Clasen
parent
f66b6e5059
commit
e63a066ced
@@ -747,6 +747,9 @@ gtk_alert_dialog_choose_finish (GtkAlertDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), -1);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_alert_dialog_choose, -1);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return (int) g_task_propagate_int (G_TASK (result), error);
|
||||
}
|
||||
|
||||
|
||||
@@ -492,6 +492,9 @@ gtk_color_dialog_choose_rgba_finish (GtkColorDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_color_dialog_choose_rgba, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
|
||||
@@ -976,6 +976,9 @@ gtk_file_dialog_open_finish (GtkFileDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_open, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return finish_file_op (self, G_TASK (result), error);
|
||||
}
|
||||
|
||||
@@ -1050,6 +1053,9 @@ gtk_file_dialog_select_folder_finish (GtkFileDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_select_folder, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return finish_file_op (self, G_TASK (result), error);
|
||||
}
|
||||
|
||||
@@ -1120,6 +1126,9 @@ gtk_file_dialog_save_finish (GtkFileDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_save, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return finish_file_op (self, G_TASK (result), error);
|
||||
}
|
||||
|
||||
@@ -1194,6 +1203,9 @@ gtk_file_dialog_open_multiple_finish (GtkFileDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_open_multiple, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return finish_multiple_files_op (self, G_TASK (result), error);
|
||||
}
|
||||
|
||||
@@ -1268,6 +1280,9 @@ gtk_file_dialog_select_multiple_folders_finish (GtkFileDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_file_dialog_select_multiple_folders, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return finish_multiple_files_op (self, G_TASK (result), error);
|
||||
}
|
||||
|
||||
|
||||
@@ -697,6 +697,9 @@ gtk_font_dialog_choose_family_finish (GtkFontDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_family, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
@@ -777,6 +780,9 @@ gtk_font_dialog_choose_face_finish (GtkFontDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_face, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
@@ -855,6 +861,9 @@ gtk_font_dialog_choose_font_finish (GtkFontDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), NULL);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_font, NULL);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
|
||||
return g_task_propagate_pointer (G_TASK (result), error);
|
||||
}
|
||||
|
||||
@@ -944,6 +953,8 @@ gtk_font_dialog_choose_font_and_features_finish (GtkFontDialog *self,
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), FALSE);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_font_dialog_choose_font_and_features, FALSE);
|
||||
|
||||
/* Destroy the dialog window not to be bound to GTask lifecycle */
|
||||
g_task_set_task_data (G_TASK (result), NULL, NULL);
|
||||
font_result = g_task_propagate_pointer (G_TASK (result), error);
|
||||
|
||||
if (font_result)
|
||||
|
||||
Reference in New Issue
Block a user