Fix issue from rev 6994 "Run DRC" from plot dialog crashes on Linux.

This commit is contained in:
jean-pierre charras 2016-07-28 14:07:35 +02:00
parent ff246f6365
commit e15ad9350f
5 changed files with 66 additions and 28 deletions

View File

@ -69,7 +69,7 @@ void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event )
// in lists
SetReturnCode( wxID_CANCEL );
Close();
m_tester->DestroyDialog( wxID_CANCEL );
m_tester->DestroyDRCDialog( wxID_CANCEL );
return;
}
@ -300,7 +300,9 @@ void DIALOG_DRC_CONTROL::OnOkClick( wxCommandEvent& event )
SetReturnCode( wxID_OK );
SetDrcParmeters();
m_tester->DestroyDialog( wxID_OK );
// The dialog can be modal or not modal.
// Leave the DRC caller destroy (or not) the dialog
m_tester->DestroyDRCDialog( wxID_OK );
}
@ -308,7 +310,9 @@ void DIALOG_DRC_CONTROL::OnCancelClick( wxCommandEvent& event )
{
SetReturnCode( wxID_CANCEL );
m_tester->DestroyDialog( wxID_CANCEL );
// The dialog can be modal or not modal.
// Leave the DRC caller destroy (or not) the dialog
m_tester->DestroyDRCDialog( wxID_CANCEL );
}
@ -342,13 +346,16 @@ void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event )
m_brdEditor->CursorGoto( item->GetPointA() );
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) );
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
// no destruction so we can preserve listbox cursor
Show( false );
if( !IsModal() )
{
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
// no destruction so we can preserve listbox cursor
Show( false );
// We do not want the clarification popup window.
// when releasing the left button in the main window
m_brdEditor->SkipNextLeftButtonReleaseEvent();
// We do not want the clarification popup window.
// when releasing the left button in the main window
m_brdEditor->SkipNextLeftButtonReleaseEvent();
}
}
}
}
@ -395,7 +402,8 @@ void DIALOG_DRC_CONTROL::OnPopupMenu( wxCommandEvent& event )
m_brdEditor->CursorGoto( pos );
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) );
Show( false );
if( !IsModal() )
Show( false );
}
}
@ -475,11 +483,14 @@ void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
m_brdEditor->CursorGoto( item->GetPointA() );
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) );
Show( false );
if( !IsModal() )
{
Show( false );
// We do not want the clarification popup window.
// when releasing the left button in the main window
m_brdEditor->SkipNextLeftButtonReleaseEvent();
// We do not want the clarification popup window.
// when releasing the left button in the main window
m_brdEditor->SkipNextLeftButtonReleaseEvent();
}
}
}
}

View File

@ -823,10 +823,10 @@ void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
{
// First close an existing dialog if open
// (low probability, but can happen)
parent->GetDrcController()->DestroyDialog( wxID_OK );
parent->GetDrcController()->DestroyDRCDialog( wxID_OK );
// Open a new drc dialod, with the right parent frame
parent->GetDrcController()->ShowDialog( this );
// Open a new drc dialod, with the right parent frame, and in Modal Mode
parent->GetDrcController()->ShowDRCDialog( this );
}
}

View File

@ -53,8 +53,20 @@
#include <wx/progdlg.h>
void DRC::ShowDialog( wxWindow* aParent )
void DRC::ShowDRCDialog( wxWindow* aParent )
{
bool show_dlg_modal = true;
// the dialog needs a parent frame. if it is not specified, this is
// the PCB editor frame specified in DRC class.
if( aParent == NULL )
{
// if any parent is specified, the dialog is modal.
// if this is the default PCB editor frame, it is not modal
show_dlg_modal = false;
aParent = m_pcbEditorFrame;
}
if( !m_drcDialog )
{
m_pcbEditorFrame->GetToolManager()->RunAction( COMMON_ACTIONS::selectionClear, true );
@ -62,15 +74,21 @@ void DRC::ShowDialog( wxWindow* aParent )
updatePointers();
m_drcDialog->SetRptSettings( m_doCreateRptFile, m_rptFilename);
}
else
updatePointers();
m_drcDialog->Show( true );
if( show_dlg_modal )
m_drcDialog->ShowModal();
else
m_drcDialog->Show( true );
}
else // The dialog is just not visible (because the user has double clicked on an error item)
{
updatePointers();
m_drcDialog->Show( true );
}
}
void DRC::DestroyDialog( int aReason )
void DRC::DestroyDRCDialog( int aReason )
{
if( m_drcDialog )
{

View File

@ -437,22 +437,29 @@ public:
/**
* Function ShowDialog
* Function ShowDRCDialog
* opens a dialog and prompts the user, then if a test run button is
* clicked, runs the test(s) and creates the MARKERS. The dialog is only
* created if it is not already in existence.
* @param aParent is the parent window for wxWidgets. Usually the PCB editor frame
* but can be an other dialog
* if aParent == NULL (default), the parent will be the PCB editor frame
* and the dialog will be not modal (just float on parent
* if aParent is specified, the dialog will be modal.
* The modal mode is mandatory if the dialog is created from an other dialog, not
* from the PCB editor frame
*/
void ShowDialog( wxWindow* aParent );
void ShowDRCDialog( wxWindow* aParent = NULL );
/**
* Function DestroyDialog
* Function DestroyDRCDialog
* deletes this ui dialog box and zeros out its pointer to remember
* the state of the dialog's existence.
* @param aReason Indication of which button was clicked to cause the destruction.
* if aReason == wxID_OK, design parameters values which can be entered from the dialog will bbe saved
* in design parameters list
*/
void DestroyDialog( int aReason );
void DestroyDRCDialog( int aReason );
/**

View File

@ -294,7 +294,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_DRC_CONTROL:
m_drc->ShowDialog( this );
// Shows the DRC dialog in non modal mode, to allows board edition
// with the DRC dialog opened and showing errors.
m_drc->ShowDRCDialog();
break;
case ID_GET_NETLIST: