GNOME Bugzilla – Bug 434535
printoperation's create_surface doesn't check temp file creation for success
Last modified: 2008-07-01 05:39:05 UTC
_gtk_print_operation_platform_backend_create_preview_surface creates a temp file, but doesn't check whether the operation succeeded (fd >= 0) before proceeding to use the FD.
Unfortunately, there is no really good way to handle that failure right now.
Maybe _gtk_print_operation_platform_backend_create_preview_surface could return NULL, gtk_print_operation_preview_handler check it and return FALSE, and gtkprintoperation.c:print_pages signal the error, instead of aborting with g_error?
Yes, thats probably what needs to happen here.
Created attachment 112908 [details] [review] Patch checking temp file creation success. Hi all, this patch implements checking of temp file creation success. Marek
Looks mostly ok, but you should separate the programming error gtk_print_context_get_cairo_context (priv->print_context) == NULL from the runtime error !handled and keep the g_error () for the programming error
Created attachment 112970 [details] [review] Reworked patch. Hi, this is reworked patch. It is reworked according to previous comment. Marek
+ gtk_dialog_run (GTK_DIALOG (error_dialog)); Print operations may run async, in which case they must never block. Using gtk_dialog_run is therefore unacceptable. I think just showing the dialogue and connecting "response" to gtk_widget_destroy would do here.
Created attachment 112985 [details] [review] Re-reworked patch :) Hi Christian, thank you for your comment. I reworked the patch according to it. Marek
Thanks, looks good now. One stylistic nit is that you may want to say "a temporary file" not just "temporary file".
Yes, that is exactly what I want to say. :-)
Created attachment 113538 [details] [review] Patch without the typo.
* gtk/gtkprintoperation-unix.c (_gtk_print_operation_platform_backend_create_preview_surface): Handle failure to create temp file by returning NULL. * gtk/gtkprintoperation.c (gtk_print_operation_preview_handler): Return FALSE if surface creation fails. (print_pages): If the preiew signal is not handled, show an error dialog.