wxPrinter dialog Generates Assertions on Linux

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

wxPrinter dialog Generates Assertions on Linux

Post by rsb »

Hello,

We're using the wxPrinter class for printing. We have a setup routine that allows a user to select a printer
from the dialog that's invoked using the wxPrinter::PrintDialog method. Here's a snippet:

------------------------------------------------------------------------------------------------------
wxPrintDialogData initPrintDialogData(pFrame->GetPrintData());
wxPrinter printer(&initPrintDialogData);

wxDC *pDC = printer.PrintDialog(pFrame) ;
if( !pDC )
{
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
{
wxMessageBox(_T("There was a problem printing.\nPerhaps your current printer is not set correctly?"), _T("Printing"), wxOK);
}
}
------------------------------------------------------------------------------------------------------

When I Okay the dialog using the Print button (See Picture Below), I get the following assertion errors:

(mozaix_ln:12023): Gtk-CRITICAL **: IA__gtk_print_context_create_pango_context: assertion `GTK_IS_PRINT_CONTEXT (context)' failed
(mozaix_ln:12023): Gtk-CRITICAL **: IA__gtk_print_context_create_pango_layout: assertion `GTK_IS_PRINT_CONTEXT (context)' failed
(mozaix_ln:12023): Gtk-CRITICAL **: IA__gtk_print_context_get_cairo_context: assertion `GTK_IS_PRINT_CONTEXT (context)' failed

We use the same routine on Windows with no problems. Any idea what would cause these errors.

A secondary problem is that the paper size is always undefined, returns -1, -1.

We're using wxWidgets 3.1.0 on Linux - Red Hat Enterprise Linux Workstation release 6.9 (Santiago)
PrintDialogLinux.PNG
PrintDialogLinux.PNG (41.19 KiB) Viewed 1966 times
Thanks,
RSB
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: wxPrinter dialog Generates Assertions on Linux

Post by rsb »

Compiler: gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxPrinter dialog Generates Assertions on Linux

Post by ONEEYEMAN »

Hi,
Can you reproduce the issue in the printing sample?

About the second one: I vaguely remember that there was an issue with the paper size in the printer dialog on *nix. I don't remember if it was fixed or not.

Again, see if the sample works correctly for you.

Thank you.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: wxPrinter dialog Generates Assertions on Linux

Post by rsb »

Hi,

I'm not able to reproduce it in the sample but the sample doesn't use the PrintDialog method. It uses
the Print method with the prompt operand set to true which invokes the dialog.

Thanks.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxPrinter dialog Generates Assertions on Linux

Post by ONEEYEMAN »

Hi,
So why not follow the sample and do it the same way?
What is the problem with it?

Or even better - can you modify the sample to do the same thing as your code and see if it will work?

Thank you.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: wxPrinter dialog Generates Assertions on Linux

Post by rsb »

Hi,

Okay, I just rebuilt the sample using the PrintDialog method in place of the Print method and now I do get the same errors.

The reason we do it this way is because we want to be able to define the Printer and Page setup before we print.

Thanks.

$ ./printing
(printing:13375): Gtk-CRITICAL **: IA__gtk_print_context_create_pango_context: assertion `GTK_IS_PRINT_CONTEXT (context)' failed

(printing:13375): Gtk-CRITICAL **: IA__gtk_print_context_create_pango_layout: assertion `GTK_IS_PRINT_CONTEXT (context)' failed

(printing:13375): Gtk-CRITICAL **: IA__gtk_print_context_get_cairo_context: assertion `GTK_IS_PRINT_CONTEXT (context)' failed
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxPrinter dialog Generates Assertions on Linux

Post by ONEEYEMAN »

Hi,
The whole reason why the print dialog exist is to let the user select the printer he wants.
If you have on;y one printer or no printer at all and you don't need a selection, why not just invoke a printing function yourself?

Thank you.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: wxPrinter dialog Generates Assertions on Linux

Post by rsb »

Hi,

We have many printers. We just want to select the printer and the page setup first.

In our dialog, we have a Printer setup button and a Page setup button. Users will select the printer from many
listed in the print dialog and then the page setup, they will then select other application specific options and
after that they will print.

When they print, we invoke the wxPrinter::Print method with the prompt operand set to false.

Thanks.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxPrinter dialog Generates Assertions on Linux

Post by ONEEYEMAN »

Hi,
I don't think you can do it like this in *nix/GTK.
The PrinterDC wxWidgets creates is based on the printer selection which comes from the wxPrinterDialogData. Then based on this DC the number of pages is calculated.

Remember, in *nix world you need something rendered in order to get its dimensions. Or in you case you have to have a proper printer data to create a DC and then calculate how many pages it will print.

So you choice is either rewrite you code as in the sample or copy wx code with the #ifdef to make it work properly.

Or I misunderstand your problem?

Thank you.
rsb
I live to help wx-kind
I live to help wx-kind
Posts: 170
Joined: Fri May 29, 2015 7:26 pm

Re: wxPrinter dialog Generates Assertions on Linux

Post by rsb »

Hi,

OK, that makes sense now.

Thanks very much!
Post Reply