Eeschema: fix crash when closing or moving the print preview frame on Windows 7 (at least version 32 and compiled with mingw/ GCC 5.2)
This commit is contained in:
commit
23d0de1bda
|
@ -76,17 +76,15 @@ 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,25 +92,20 @@ 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 remembers its size and position during a session
|
||||||
*/
|
*/
|
||||||
class SCH_PREVIEW_FRAME : public wxPreviewFrame
|
class SCH_PREVIEW_FRAME : public wxPreviewFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SCH_PREVIEW_FRAME( wxPrintPreview* aPreview, DIALOG_PRINT_USING_PRINTER* aParent,
|
SCH_PREVIEW_FRAME( wxPrintPreview* aPreview, wxWindow* aParent,
|
||||||
const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition,
|
const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition,
|
||||||
const wxSize& aSize = wxDefaultSize ) :
|
const wxSize& aSize = wxDefaultSize ) :
|
||||||
wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
|
wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +127,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 +245,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 +285,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,23 +303,22 @@ 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();
|
|
||||||
msg.Printf( _( "Print page %d" ), page );
|
msg.Printf( _( "Print page %d" ), page );
|
||||||
parent->ClearMsgPanel();
|
m_parent->ClearMsgPanel();
|
||||||
parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
|
m_parent->AppendMsgPanel( msg, wxEmptyString, CYAN );
|
||||||
|
|
||||||
SCH_SCREEN* screen = parent->GetScreen();
|
SCH_SCREEN* screen = m_parent->GetScreen();
|
||||||
SCH_SHEET_PATH oldsheetpath = parent->GetCurrentSheet();
|
SCH_SHEET_PATH oldsheetpath = m_parent->GetCurrentSheet();
|
||||||
SCH_SHEET_PATH list;
|
SCH_SHEET_PATH list;
|
||||||
SCH_SHEET_LIST SheetList( NULL );
|
SCH_SHEET_LIST SheetList( NULL );
|
||||||
SCH_SHEET_PATH* sheetpath = SheetList.GetSheet( page - 1 );
|
SCH_SHEET_PATH* sheetpath = SheetList.GetSheet( page - 1 );
|
||||||
|
|
||||||
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
||||||
{
|
{
|
||||||
parent->SetCurrentSheet( list );
|
m_parent->SetCurrentSheet( list );
|
||||||
parent->GetCurrentSheet().UpdateAllScreenReferences();
|
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||||
parent->SetSheetNumberAndCount();
|
m_parent->SetSheetNumberAndCount();
|
||||||
screen = parent->GetCurrentSheet().LastScreen();
|
screen = m_parent->GetCurrentSheet().LastScreen();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -346,9 +329,9 @@ bool SCH_PRINTOUT::OnPrintPage( int page )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DrawPage( screen );
|
DrawPage( screen );
|
||||||
parent->SetCurrentSheet( oldsheetpath );
|
m_parent->SetCurrentSheet( oldsheetpath );
|
||||||
parent->GetCurrentSheet().UpdateAllScreenReferences();
|
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
||||||
parent->SetSheetNumberAndCount();
|
m_parent->SetSheetNumberAndCount();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -379,18 +362,17 @@ bool SCH_PRINTOUT::OnBeginDocument( int startPage, int endPage )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
SCH_EDIT_FRAME* parent = m_parent->GetParent();
|
|
||||||
wxLogDebug( wxT( "Printer name: " ) +
|
wxLogDebug( wxT( "Printer name: " ) +
|
||||||
parent->GetPageSetupData().GetPrintData().GetPrinterName() );
|
m_parent->GetPageSetupData().GetPrintData().GetPrinterName() );
|
||||||
wxLogDebug( wxT( "Paper ID: %d" ),
|
wxLogDebug( wxT( "Paper ID: %d" ),
|
||||||
parent->GetPageSetupData().GetPrintData().GetPaperId() );
|
m_parent->GetPageSetupData().GetPrintData().GetPaperId() );
|
||||||
wxLogDebug( wxT( "Color: %d" ),
|
wxLogDebug( wxT( "Color: %d" ),
|
||||||
(int) parent->GetPageSetupData().GetPrintData().GetColour() );
|
(int)m_parent->GetPageSetupData().GetPrintData().GetColour() );
|
||||||
wxLogDebug( wxT( "Monochrome: %d" ), parent->GetPrintMonochrome() );
|
wxLogDebug( wxT( "Monochrome: %d" ), m_parent->GetPrintMonochrome() );
|
||||||
wxLogDebug( wxT( "Orientation: %d:" ),
|
wxLogDebug( wxT( "Orientation: %d:" ),
|
||||||
parent->GetPageSetupData().GetPrintData().GetOrientation() );
|
m_parent->GetPageSetupData().GetPrintData().GetOrientation() );
|
||||||
wxLogDebug( wxT( "Quality: %d"),
|
wxLogDebug( wxT( "Quality: %d"),
|
||||||
parent->GetPageSetupData().GetPrintData().GetQuality() );
|
m_parent->GetPageSetupData().GetPrintData().GetQuality() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -409,8 +391,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();
|
EDA_DRAW_PANEL* panel = m_parent->GetCanvas();
|
||||||
EDA_DRAW_PANEL* panel = parent->GetCanvas();
|
|
||||||
|
|
||||||
wxBusyCursor dummy;
|
wxBusyCursor dummy;
|
||||||
|
|
||||||
|
@ -427,7 +408,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
|
||||||
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
|
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
|
||||||
|
|
||||||
// Change scale factor and offset to print the whole page.
|
// Change scale factor and offset to print the whole page.
|
||||||
bool printReference = parent->GetPrintSheetReference();
|
bool printReference = m_parent->GetPrintSheetReference();
|
||||||
|
|
||||||
pageSizeIU = aScreen->GetPageSettings().GetSizeIU();
|
pageSizeIU = aScreen->GetPageSettings().GetSizeIU();
|
||||||
FitThisSizeToPaper( pageSizeIU );
|
FitThisSizeToPaper( pageSizeIU );
|
||||||
|
@ -462,20 +443,20 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
|
||||||
|
|
||||||
GRResetPenAndBrush( dc );
|
GRResetPenAndBrush( dc );
|
||||||
|
|
||||||
if( parent->GetPrintMonochrome() )
|
if( m_parent->GetPrintMonochrome() )
|
||||||
GRForceBlackPen( true );
|
GRForceBlackPen( true );
|
||||||
|
|
||||||
aScreen->m_IsPrinting = true;
|
aScreen->m_IsPrinting = true;
|
||||||
|
|
||||||
EDA_COLOR_T bg_color = GetSchFrameParent()->GetDrawBgColor();
|
EDA_COLOR_T bg_color = m_parent->GetDrawBgColor();
|
||||||
|
|
||||||
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
|
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
|
||||||
|
|
||||||
if( printReference )
|
if( printReference )
|
||||||
parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
|
m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
|
||||||
IU_PER_MILS, aScreen->GetFileName() );
|
IU_PER_MILS, aScreen->GetFileName() );
|
||||||
|
|
||||||
GetSchFrameParent()->SetDrawBgColor( bg_color );
|
m_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