Eeschema: fix crashes when closing or moving the print preview frame on Windows 7
This commit is contained in:
parent
845638fc63
commit
a0b31b62ba
|
@ -76,17 +76,16 @@ private:
|
||||||
class SCH_PRINTOUT : public wxPrintout
|
class SCH_PRINTOUT : public wxPrintout
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
DIALOG_PRINT_USING_PRINTER* m_parent;
|
SCH_EDIT_FRAME* m_parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SCH_PRINTOUT( DIALOG_PRINT_USING_PRINTER* aParent, const wxString& aTitle ) :
|
SCH_PRINTOUT( SCH_EDIT_FRAME* aParent, const wxString& aTitle ) :
|
||||||
wxPrintout( aTitle )
|
wxPrintout( aTitle )
|
||||||
{
|
{
|
||||||
wxASSERT( aParent != NULL );
|
wxASSERT( aParent != NULL );
|
||||||
|
|
||||||
m_parent = aParent;
|
m_parent = aParent;
|
||||||
}
|
}
|
||||||
SCH_EDIT_FRAME* GetSchFrameParent() { return m_parent->GetParent(); }
|
|
||||||
bool OnPrintPage( int page );
|
bool OnPrintPage( int page );
|
||||||
bool HasPage( int page );
|
bool HasPage( int page );
|
||||||
bool OnBeginDocument( int startPage, int endPage );
|
bool OnBeginDocument( int startPage, int endPage );
|
||||||
|
@ -94,9 +93,9 @@ public:
|
||||||
void DrawPage( SCH_SCREEN* aScreen );
|
void DrawPage( SCH_SCREEN* aScreen );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom schematic print preview frame.
|
* Custom schematic print preview frame.
|
||||||
|
* This derived preview frame remember its size and position during a session
|
||||||
*/
|
*/
|
||||||
class SCH_PREVIEW_FRAME : public wxPreviewFrame
|
class SCH_PREVIEW_FRAME : public wxPreviewFrame
|
||||||
{
|
{
|
||||||
|
@ -108,11 +107,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DIALOG_PRINT_USING_PRINTER* GetParent()
|
|
||||||
{
|
|
||||||
return ( DIALOG_PRINT_USING_PRINTER* )wxWindow::GetParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Show( bool show ) // overload
|
bool Show( bool show ) // overload
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
|
@ -134,27 +128,18 @@ public:
|
||||||
|
|
||||||
ret = wxPreviewFrame::Show( show );
|
ret = wxPreviewFrame::Show( show );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static wxPoint s_pos;
|
static wxPoint s_pos;
|
||||||
static wxSize s_size;
|
static wxSize s_size;
|
||||||
|
|
||||||
DECLARE_CLASS( SCH_PREVIEW_FRAME )
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
DECLARE_NO_COPY_CLASS( SCH_PREVIEW_FRAME )
|
|
||||||
};
|
};
|
||||||
|
|
||||||
wxPoint SCH_PREVIEW_FRAME::s_pos;
|
wxPoint SCH_PREVIEW_FRAME::s_pos;
|
||||||
wxSize SCH_PREVIEW_FRAME::s_size;
|
wxSize SCH_PREVIEW_FRAME::s_size;
|
||||||
|
|
||||||
IMPLEMENT_CLASS( SCH_PREVIEW_FRAME, wxPreviewFrame )
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE( SCH_PREVIEW_FRAME, wxPreviewFrame )
|
|
||||||
EVT_CLOSE( SCH_PREVIEW_FRAME::OnCloseWindow )
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
|
|
||||||
DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent ) :
|
DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent ) :
|
||||||
DIALOG_PRINT_USING_PRINTER_BASE( aParent )
|
DIALOG_PRINT_USING_PRINTER_BASE( aParent )
|
||||||
|
@ -261,8 +246,8 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
|
||||||
|
|
||||||
// Pass two printout objects: for preview, and possible printing.
|
// Pass two printout objects: for preview, and possible printing.
|
||||||
wxString title = _( "Preview" );
|
wxString title = _( "Preview" );
|
||||||
wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( this, title ),
|
wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( parent, title ),
|
||||||
new SCH_PRINTOUT( this, title ),
|
new SCH_PRINTOUT( parent, title ),
|
||||||
&parent->GetPageSetupData().GetPrintData() );
|
&parent->GetPageSetupData().GetPrintData() );
|
||||||
|
|
||||||
if( preview == NULL )
|
if( preview == NULL )
|
||||||
|
@ -301,7 +286,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
|
||||||
printDialogData.EnablePageNumbers( true );
|
printDialogData.EnablePageNumbers( true );
|
||||||
|
|
||||||
wxPrinter printer( &printDialogData );
|
wxPrinter printer( &printDialogData );
|
||||||
SCH_PRINTOUT printout( this, _( "Print Schematic" ) );
|
SCH_PRINTOUT printout( parent, _( "Print Schematic" ) );
|
||||||
|
|
||||||
if( !printer.Print( this, &printout, true ) )
|
if( !printer.Print( this, &printout, true ) )
|
||||||
{
|
{
|
||||||
|
@ -319,7 +304,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
|
||||||
bool SCH_PRINTOUT::OnPrintPage( int page )
|
bool SCH_PRINTOUT::OnPrintPage( int page )
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
SCH_EDIT_FRAME* parent = m_parent->GetParent();
|
SCH_EDIT_FRAME* parent = m_parent;
|
||||||
msg.Printf( _( "Print page %d" ), page );
|
msg.Printf( _( "Print page %d" ), page );
|
||||||
parent->ClearMsgPanel();
|
parent->ClearMsgPanel();
|
||||||
parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
|
parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
|
||||||
|
@ -379,7 +364,7 @@ bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
SCH_EDIT_FRAME* parent = m_parent->GetParent();
|
SCH_EDIT_FRAME* parent = m_parent;
|
||||||
wxLogDebug( wxT( "Printer name: " ) +
|
wxLogDebug( wxT( "Printer name: " ) +
|
||||||
parent->GetPageSetupData().GetPrintData().GetPrinterName() );
|
parent->GetPageSetupData().GetPrintData().GetPrinterName() );
|
||||||
wxLogDebug( wxT( "Paper ID: %d" ),
|
wxLogDebug( wxT( "Paper ID: %d" ),
|
||||||
|
@ -409,7 +394,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
|
||||||
EDA_RECT oldClipBox;
|
EDA_RECT oldClipBox;
|
||||||
wxRect fitRect;
|
wxRect fitRect;
|
||||||
wxDC* dc = GetDC();
|
wxDC* dc = GetDC();
|
||||||
SCH_EDIT_FRAME* parent = m_parent->GetParent();
|
SCH_EDIT_FRAME* parent = m_parent;
|
||||||
EDA_DRAW_PANEL* panel = parent->GetCanvas();
|
EDA_DRAW_PANEL* panel = parent->GetCanvas();
|
||||||
|
|
||||||
wxBusyCursor dummy;
|
wxBusyCursor dummy;
|
||||||
|
@ -467,7 +452,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
|
||||||
|
|
||||||
aScreen->m_IsPrinting = true;
|
aScreen->m_IsPrinting = true;
|
||||||
|
|
||||||
EDA_COLOR_T bg_color = GetSchFrameParent()->GetDrawBgColor();
|
EDA_COLOR_T bg_color = parent->GetDrawBgColor();
|
||||||
|
|
||||||
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
|
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
|
||||||
|
|
||||||
|
@ -475,7 +460,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
|
||||||
parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
|
parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
|
||||||
IU_PER_MILS, aScreen->GetFileName() );
|
IU_PER_MILS, aScreen->GetFileName() );
|
||||||
|
|
||||||
GetSchFrameParent()->SetDrawBgColor( bg_color );
|
parent->SetDrawBgColor( bg_color );
|
||||||
aScreen->m_IsPrinting = false;
|
aScreen->m_IsPrinting = false;
|
||||||
panel->SetClipBox( oldClipBox );
|
panel->SetClipBox( oldClipBox );
|
||||||
|
|
||||||
|
|
|
@ -463,6 +463,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
|
||||||
|
|
||||||
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
|
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
|
||||||
frame->SetMinSize( wxSize( 550, 350 ) );
|
frame->SetMinSize( wxSize( 550, 350 ) );
|
||||||
|
frame->Center();
|
||||||
|
|
||||||
frame->Initialize();
|
frame->Initialize();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue