Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wxGTK 2.9.2 crash when printing

68 views
Skip to first unread message

Buzz

unread,
Oct 5, 2011, 2:04:57 PM10/5/11
to
Hi,

I'm afraid there's a little bug when printing a richtext control, on
wxGTK.

Easy to reproduce :

I take the richtext sample,
go to File->Print
click Cancel on the print dialog

go back to File->Print ==> Kaboom....


I get the following stack trace

ASSERT INFO:
./src/gtk/print.cpp(923): assert "Assert failure" failed in Print():
The print dialog returned an error.

BACKTRACE:
[1] wxOnAssert(char const*, int, char const*, char const*, wxString
const&)
[2] wxGtkPrinter::Print(wxWindow*, wxPrintout*, bool)
[3] wxPrinter::Print(wxWindow*, wxPrintout*, bool)
[4] wxRichTextPrinting::DoPrint(wxRichTextPrintout*)
[5] wxRichTextPrinting::PrintBuffer(wxRichTextBuffer const&)
[6] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&,
wxEvent&) cons)
[7] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase
const&, wxEvtHandler*, wxEvent&)
[8] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[9] wxEvtHandler::TryHereOnly(wxEvent&)
[10] wxEvtHandler::ProcessEventLocally(wxEvent&)
[11] wxEvtHandler::ProcessEvent(wxEvent&)
[12] wxEvtHandler::SafelyProcessEvent(wxEvent&)
[13] wxMenuBase::SendEvent(int, int)
[14] menuitem_activate() menu.cpp
[15] g_cclosure_marshal_VOID__VOID()
[16] g_closure_invoke()
[17] g_signal_emit_valist()
[18] g_signal_emit()
[19] gtk_widget_activate()
[20] gtk_menu_shell_activate_item()
[21] g_closure_invoke()
[22] g_signal_emit_valist()
[23] g_signal_emit()
[24] gtk_propagate_event()
[25] gtk_main_do_event()
[26] g_main_context_dispatch()
[27] g_main_loop_run()
[28] gtk_main()

I'm using Ubuntu 10.04 running inside a Parallels Desktop VM.

Is it a bug or something wrong on my system ?

Vadim Zeitlin

unread,
Oct 7, 2011, 11:29:41 AM10/7/11
to
On 2011-10-05, Buzz <michel....@gmail.com> wrote:
> I'm afraid there's a little bug when printing a richtext control, on
> wxGTK.
>
> Easy to reproduce :
>
> I take the richtext sample,
> go to File->Print
> click Cancel on the print dialog
>
> go back to File->Print ==> Kaboom....
>
>
> I get the following stack trace
>
> ASSERT INFO:
> ./src/gtk/print.cpp(923): assert "Assert failure" failed in Print():
> The print dialog returned an error.

Could you please check what kind of error did it return?

> Is it a bug or something wrong on my system ?

I think it's a bug but you should check whether printing works from other
GTK applications on the same (virtual) system.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Buzz

unread,
Nov 1, 2011, 11:31:41 AM11/1/11
to
On 7 oct, 16:29, Vadim Zeitlin <va...@wxwidgets.org> wrote:
Hi,

sorry for my late answer...

I tested printing from other applications, on the same virtual
machine. I tried with Gedit end Eog, but it works fine there.

What do you mean by "the kind of error it returns" ?

I just get a message box that says :
./src/gtk/print.cpp(923) : asset "Assert failure" failed in Print() :
the print dialog returned an error.

Kind regards,
Buzz.

Vadim Zeitlin

unread,
Nov 2, 2011, 12:09:37 PM11/2/11
to
> I tested printing from other applications, on the same virtual
> machine. I tried with Gedit end Eog, but it works fine there.

So this is indeed a wxWidgets bug then...

> What do you mean by "the kind of error it returns" ?

It wasn't clear to me which error exactly occurred, I understand it better
now.

> I just get a message box that says :
> ./src/gtk/print.cpp(923) : asset "Assert failure" failed in Print() :
> the print dialog returned an error.

Does the dialog even appear on screen?

Anyhow, I don't really know what's going on here, I'd suggest building a
debug version of wxWidgets and tracing inside wxGtkPrintDialog::ShowModal()
call which happens in print.cpp(915). Please let us know if you find
anything.

Good luck,

Buzz

unread,
Nov 10, 2011, 4:34:19 PM11/10/11
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.
0 new messages