From 1f3fe6fefb77fdbcd80ee673e0167d3ff3585942 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 3 Apr 2017 07:58:34 +0200 Subject: [PATCH] Fix Eeschema: Part library editor "save current library as" crash if no current library selected. Fixes: lp:1678698 https://bugs.launchpad.net/kicad/+bug/1678698 --- eeschema/libedit.cpp | 9 +++++---- eeschema/libeditframe.cpp | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index eadf7d5bff..2fcc666915 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -291,10 +291,11 @@ void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) void LIB_EDIT_FRAME::OnSaveActiveLibrary( wxCommandEvent& event ) { bool newFile = false; + if( event.GetId() == ID_LIBEDIT_SAVE_CURRENT_LIB_AS ) newFile = true; - this->SaveActiveLibrary( newFile ); + SaveActiveLibrary( newFile ); } @@ -307,15 +308,15 @@ bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile ) PART_LIB* lib = GetCurLib(); - // Just in case the library hasn't been cached yet. - lib->GetCount(); - if( !lib ) { DisplayError( this, _( "No library specified." ) ); return false; } + // Just in case the library hasn't been cached yet. + lib->GetCount(); + wxString oldFileName = lib->GetFullFileName(); if( GetScreen()->IsModify() ) diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index b1576359f6..b18b07d1f7 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -166,6 +166,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo ) EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib ) + EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib ) EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnUpdateViewDoc ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_PIN, LIB_EDIT_FRAME::OnUpdatePinByPin ) EVT_UPDATE_UI( ID_LIBEDIT_EDIT_PIN_BY_TABLE, LIB_EDIT_FRAME::OnUpdatePinTable )