Buzz
unread,Nov 10, 2011, 4:34:19 PM11/10/11You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hi,
First things first, beware that my C++ knowledge is rather basic, and
this GTK printing stuff looks pretty complex to me. So I'm not sure
the fix I propose will be the best one...
So, to sum up, it crashes on Linux, the second time you print a
document. Whether you've cancelled the first print or not.
This is the error :
Gtk-CRITICAL **: gtk_print_operation_run: assertion `op->priv->status
== GTK_PRINT_STATUS_INITIAL' failed
This is in gtk/print.cpp, following the call to
gtk_print_operation_run, on line 659 (from the official
wxWidgets-2.9.2 source).
gtk_print_operation_run takes GtkPrintOperation as one of its
parameters, and I have the feeling that the same GtkPrintOperation
instance cannot be used for multiple prints. The first time, it's OK,
but after that, GtkPrintOperation.status always gets the
GTK_PRINT_STATUS_FINISHED_ABORTED value, which causes the crash.
The only fix I could think of was to create a new GtkPrintOperation
instance after each print. But to avoid losing the page settings that
the user had entered during the first print (pages per side,
scale, ...), I created a little method inside of wxGtkPrintNativeData,
called RenewPrintJob(), that copies the necessary properties from the
old GtkPrintOperation into a new one.
That fixes the problem.
Among the things I still don't understand, I tried to free() the old
GtkPrintOperation, but this caused a crash, complaining that the
pointer was invalid... even though this pointer seemed OK to me...
Here's a diff between the official 2.9.2 gtk/print.cpp source, and the
modified one :
582a583,595
>
> // Replace the m_job property by a new instance of GtkPrintOperation,
> // preserving the settings from the previous print
> void wxGtkPrintNativeData::RenewPrintJob()
> {
> GtkPrintOperation *tmp = gtk_print_operation_new();
> gtk_print_operation_set_default_page_setup(tmp, gtk_print_operation_get_default_page_setup(m_job));
> gtk_print_operation_set_print_settings (tmp, gtk_print_operation_get_print_settings (m_job));
> // delete m_job;
> m_job = tmp;
> }
>
>
657a671
>
662a677
> native->RenewPrintJob();
and the corresponding diff for the include/wx/gtk/print.h file:
199a200
> void RenewPrintJob();
Don't know if this will help ... I guess someone with better
GtkPrinting knowledge will find a cleaner solution.
If you find a better fix, please let me know : I'd be curious to see
your way of doing ... :-)
Kind regards, Buzz.