Commit 53931bcf authored by Matthias Clasen's avatar Matthias Clasen

Better version of the previous patch

svn path=/trunk/; revision=17712
parent 4ae147c8
......@@ -10,7 +10,7 @@
* gtk/gtkprintoperation-unix.c
(_gtk_print_operation_platform_backend_launch_preview):
Don't leak a file descriptor, and don't make the error
dialog modal. (#421985, Morten Welinder)
dialog modal. (#421985, Morten Welinder, Christian Persch)
2007-04-29 Xan Lopez <xan@gnome.org>
......
......@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <glib/gstdio.h>
#include "gtkprintoperation-private.h"
#include "gtkmarshal.h"
#include "gtkmessagedialog.h"
......@@ -124,14 +125,12 @@ shell_command_substitute_file (const gchar *cmd,
gboolean *settings_filename_replaced)
{
const gchar *inptr, *start;
gchar *result;
GString *final;
g_return_val_if_fail (cmd != NULL, NULL);
g_return_val_if_fail (pdf_filename != NULL, NULL);
g_return_val_if_fail (settings_filename != NULL, NULL);
result = NULL;
final = g_string_new (NULL);
*pdf_filename_replaced = FALSE;
......@@ -170,11 +169,7 @@ shell_command_substitute_file (const gchar *cmd,
}
g_string_append (final, start);
result = final->str;
g_string_free (final, FALSE);
return result;
return g_string_free (final, FALSE);
}
void
......@@ -189,14 +184,15 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
gchar *preview_cmd;
GtkSettings *settings;
GtkPrintSettings *print_settings;
gchar *settings_filename;
gchar *settings_filename = NULL;
gchar *quoted_filename;
gchar *quoted_settings_filename;
gboolean filename_used;
gboolean settings_used;
gboolean filename_used = FALSE;
gboolean settings_used = FALSE;
GdkScreen *screen;
GError *error = NULL;
gint fd;
gboolean retval;
cairo_surface_destroy (surface);
......@@ -205,11 +201,15 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
else
screen = gdk_screen_get_default ();
settings_filename = g_build_filename (g_get_tmp_dir (), "settingsXXXXXX.ini", NULL);
fd = g_mkstemp (settings_filename);
fd = g_file_open_tmp ("settingsXXXXXX.ini", &settings_filename, &error);
if (fd < 0)
goto out;
print_settings = gtk_print_operation_get_print_settings (op);
if (!gtk_print_settings_to_file (print_settings, settings_filename, &error))
retval = gtk_print_settings_to_file (print_settings, settings_filename, &error);
close (fd);
if (!retval)
goto out;
settings = gtk_settings_get_for_screen (screen);
......@@ -233,8 +233,6 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
g_strfreev (argv);
out:
close (fd);
if (error != NULL)
{
GtkWidget *edialog;
......
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