Recreate GtkPrintOperation every time when printing in wxGTK.
Apparently reusing GtkPrintOperation is not allowed, so create a new one every time we need it. Closes #14731. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72642 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -197,6 +197,7 @@ public:
|
||||
void SetPrintConfig( GtkPrintSettings * config );
|
||||
|
||||
GtkPrintOperation* GetPrintJob() { return m_job; }
|
||||
void SetPrintJob(GtkPrintOperation *job) { m_job = job; }
|
||||
|
||||
GtkPrintContext *GetPrintContext() { return m_context; }
|
||||
void SetPrintContext(GtkPrintContext *context) {m_context = context; }
|
||||
@@ -206,6 +207,8 @@ public:
|
||||
void SetPageSetupToSettings(GtkPrintSettings* settings, GtkPageSetup* page_setup);
|
||||
|
||||
private:
|
||||
// NB: m_config is created and owned by us, but the other objects are not
|
||||
// and their accessors don't change their ref count.
|
||||
GtkPrintSettings *m_config;
|
||||
GtkPrintOperation *m_job;
|
||||
GtkPrintContext *m_context;
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/dynlib.h"
|
||||
#include "wx/paper.h"
|
||||
#include "wx/scopeguard.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -234,13 +235,12 @@ IMPLEMENT_CLASS(wxGtkPrintNativeData, wxPrintNativeDataBase)
|
||||
wxGtkPrintNativeData::wxGtkPrintNativeData()
|
||||
{
|
||||
m_config = gtk_print_settings_new();
|
||||
m_job = gtk_print_operation_new();
|
||||
m_job = NULL;
|
||||
m_context = NULL;
|
||||
}
|
||||
|
||||
wxGtkPrintNativeData::~wxGtkPrintNativeData()
|
||||
{
|
||||
g_object_unref(m_job);
|
||||
g_object_unref(m_config);
|
||||
}
|
||||
|
||||
@@ -904,7 +904,10 @@ bool wxGtkPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
||||
wxPrintData printdata = GetPrintDialogData().GetPrintData();
|
||||
wxGtkPrintNativeData *native = (wxGtkPrintNativeData*) printdata.GetNativeData();
|
||||
|
||||
GtkPrintOperation * const printOp = native->GetPrintJob();
|
||||
wxGtkObject<GtkPrintOperation> printOp(gtk_print_operation_new());
|
||||
native->SetPrintJob(printOp);
|
||||
wxON_BLOCK_EXIT_OBJ1(*native, wxGtkPrintNativeData::SetPrintJob,
|
||||
static_cast<GtkPrintOperation*>(NULL));
|
||||
|
||||
wxPrinterToGtkData dataToSend;
|
||||
dataToSend.printer = this;
|
||||
|
Reference in New Issue
Block a user