From d2eb9e073591b2fdf8f5d8fd82ae35819bdfe43b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 11 Aug 2018 17:19:24 +0200 Subject: [PATCH] Eeschema, Dialog annotate: fix incorrect management that creates a crash when try to open it a second time. Fixes: lp:1786618 https://bugs.launchpad.net/kicad/+bug/1786618 --- eeschema/dialogs/dialog_annotate.cpp | 16 ++- eeschema/dialogs/dialog_annotate_base.cpp | 2 +- eeschema/dialogs/dialog_annotate_base.fbp | 118 +++++++++++++++++++++- eeschema/dialogs/dialog_annotate_base.h | 2 +- eeschema/sch_edit_frame.cpp | 1 - eeschema/sch_edit_frame.h | 1 - 6 files changed, 129 insertions(+), 11 deletions(-) diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp index 59f1d9c9bb..7dcdfcf0e5 100644 --- a/eeschema/dialogs/dialog_annotate.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -43,6 +43,9 @@ #define KEY_ANNOTATE_ALGO_OPTION wxT( "AnnotateAlgoOption" ) #define KEY_ANNOTATE_MESSAGES_FILTER wxT( "AnnotateFilterMsg" ) +// A window name for the annotate dialog to retrieve is if not destroyed +#define DLG_WINDOW_NAME "DialogAnnotateWindowName" + class wxConfigBase; @@ -94,6 +97,7 @@ private: DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& message ) : DIALOG_ANNOTATE_BASE( parent ) { + SetName( DLG_WINDOW_NAME ); m_Parent = parent; if( !message.IsEmpty() ) @@ -313,14 +317,16 @@ int DIALOG_ANNOTATE::GetStartNumber() void SCH_EDIT_FRAME::OnAnnotate( wxCommandEvent& event ) { - if( !m_annotateDialog ) + DIALOG_ANNOTATE* dlg = static_cast ( wxWindow::FindWindowByName( DLG_WINDOW_NAME ) ); + + if( !dlg ) { - m_annotateDialog = new DIALOG_ANNOTATE( this, wxEmptyString ); - m_annotateDialog->Show( true ); + dlg = new DIALOG_ANNOTATE( this, wxEmptyString ); + dlg->Show( true ); } - else // The dialog is just not visible + else // The dialog is already opened, perhaps not visible { - m_annotateDialog->Show( true ); + dlg->Show( true ); } } diff --git a/eeschema/dialogs/dialog_annotate_base.cpp b/eeschema/dialogs/dialog_annotate_base.cpp index b87623ebdf..fc169a2128 100644 --- a/eeschema/dialogs/dialog_annotate_base.cpp +++ b/eeschema/dialogs/dialog_annotate_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Jul 11 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/eeschema/dialogs/dialog_annotate_base.fbp b/eeschema/dialogs/dialog_annotate_base.fbp index 454200b8fb..13129e5385 100644 --- a/eeschema/dialogs/dialog_annotate_base.fbp +++ b/eeschema/dialogs/dialog_annotate_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ dialog_annotate_base 1000 none + 1 dialog_annotate_base @@ -54,13 +55,20 @@ - + + + + + + + + OnClose @@ -75,17 +83,23 @@ + + + + + + @@ -135,6 +149,7 @@ 1 wxID_ANY + 0 0 @@ -160,7 +175,14 @@ 1 + + + + + + + @@ -265,7 +287,14 @@ + + + + + + + @@ -375,7 +404,14 @@ + + + + + + + @@ -467,7 +503,14 @@ + + + + + + + @@ -565,7 +608,14 @@ + + + + + + + @@ -657,7 +707,14 @@ + + + + + + + @@ -750,7 +807,14 @@ + + + + + + + @@ -869,7 +933,14 @@ + + + + + + + @@ -960,7 +1031,14 @@ + + + + + + + @@ -1054,7 +1132,14 @@ + + + + + + + @@ -1145,7 +1230,14 @@ + + + + + + + @@ -1232,7 +1324,14 @@ wxTAB_TRAVERSAL + + + + + + + @@ -1283,25 +1382,31 @@ + 1 0 1 1 + 0 0 + Dock 0 Left 1 1 + 0 0 ID_CLEAR_ANNOTATION_CMP Clear Annotation + + 0 0 @@ -1316,6 +1421,8 @@ protected 1 + + Resizable 1 @@ -1330,8 +1437,15 @@ + + + + + + OnClearAnnotationCmpClick + diff --git a/eeschema/dialogs/dialog_annotate_base.h b/eeschema/dialogs/dialog_annotate_base.h index 7ea011d4af..478fb65324 100644 --- a/eeschema/dialogs/dialog_annotate_base.h +++ b/eeschema/dialogs/dialog_annotate_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Jul 11 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index d0ca0e972c..029fd48cd1 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -365,7 +365,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): m_printMonochrome = true; m_printSheetReference = true; SetShowPageLimits( true ); - m_annotateDialog = nullptr; m_hotkeysDescrList = g_Schematic_Hokeys_Descr; m_dlgFindReplace = NULL; m_findReplaceData = new wxFindReplaceData( wxFR_DOWN ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 235bb68fc7..c257b70739 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -131,7 +131,6 @@ private: wxSize m_printDialogSize; bool m_printMonochrome; ///< Print monochrome instead of grey scale. bool m_printSheetReference; - DIALOG_ANNOTATE* m_annotateDialog; DIALOG_SCH_FIND* m_dlgFindReplace; wxPoint m_findDialogPosition; wxSize m_findDialogSize;