From 79a7fa0330fea46ac731c018e858ccea9ea0789e Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 28 May 2017 23:05:34 +0200 Subject: [PATCH] Create new instance of wxPrintDC in wxGtkPrintDialog GetPrintDC() should return a new device context created by the print dialog, not the duplicate of existing context passed from the caller (e.g. from wxGtkPrinter) through SetPrintDC(). Therefore SetPrintDC() is no longer useful and can be removed. --- include/wx/gtk/print.h | 4 +--- src/gtk/print.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/wx/gtk/print.h b/include/wx/gtk/print.h index f657838bfb..66e42100f3 100644 --- a/include/wx/gtk/print.h +++ b/include/wx/gtk/print.h @@ -80,8 +80,7 @@ public: wxPrintDialogData& GetPrintDialogData() wxOVERRIDE { return m_printDialogData; } - wxDC *GetPrintDC() wxOVERRIDE { return m_dc; } - void SetPrintDC(wxDC * printDC) { m_dc = printDC; } + wxDC *GetPrintDC() wxOVERRIDE; virtual int ShowModal() wxOVERRIDE; @@ -105,7 +104,6 @@ private: wxPrintDialogData m_printDialogData; wxWindow *m_parent; bool m_showDialog; - wxDC *m_dc; wxDECLARE_DYNAMIC_CLASS(wxGtkPrintDialog); }; diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 963b5a5b46..277ce6fad2 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -771,6 +771,11 @@ int wxGtkPrintDialog::ShowModal() return wxID_OK; } +wxDC* wxGtkPrintDialog::GetPrintDC() +{ + return new wxPrinterDC(m_printDialogData.GetPrintData()); +} + //---------------------------------------------------------------------------- // wxGtkPageSetupDialog //---------------------------------------------------------------------------- @@ -967,7 +972,6 @@ bool wxGtkPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt ) // This is used to setup the DC and // show the dialog if desired - dialog.SetPrintDC(m_dc); dialog.SetShowDialog(prompt); // doesn't necessarily show @@ -1153,7 +1157,6 @@ wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent ) { wxGtkPrintDialog dialog( parent, &m_printDialogData ); - dialog.SetPrintDC(m_dc); dialog.SetShowDialog(true); int ret = dialog.ShowModal(); @@ -1169,9 +1172,13 @@ wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent ) return NULL; } - m_printDialogData = dialog.GetPrintDialogData(); + wxDC* dc = dialog.GetPrintDC(); + if ( dc ) + { + m_printDialogData = dialog.GetPrintDialogData(); + } - return new wxPrinterDC( m_printDialogData.GetPrintData() ); + return dc; } bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) )