From a2b6c8e20abe94e88278998314f2e530678e5489 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 13 Nov 2017 12:30:03 +0100 Subject: [PATCH] Library Manager: select library when none is set for import/create new part --- eeschema/lib_export.cpp | 8 ++++++++ eeschema/libedit.cpp | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index 4de3e16a55..d1939e1a54 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -49,6 +49,14 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) m_lastDrawItem = NULL; wxString libName = getTargetLib(); + if( !m_libMgr->LibraryExists( libName ) ) + { + libName = SelectLibraryFromList(); + + if( !m_libMgr->LibraryExists( libName ) ) + return; + } + wxFileDialog dlg( this, _( "Import Symbol" ), m_mruPath, wxEmptyString, SchematicLibraryFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 82eb62e279..2ee3bcdc25 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -319,6 +319,15 @@ void LIB_EDIT_FRAME::OnCreateNewPart( wxCommandEvent& event ) { m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() ); m_drawItem = NULL; + wxString lib = getTargetLib(); + + if( !m_libMgr->LibraryExists( lib ) ) + { + lib = SelectLibraryFromList(); + + if( !m_libMgr->LibraryExists( lib ) ) + return; + } DIALOG_LIB_NEW_COMPONENT dlg( this ); dlg.SetMinSize( dlg.GetSize() ); @@ -335,8 +344,6 @@ void LIB_EDIT_FRAME::OnCreateNewPart( wxCommandEvent& event ) wxString name = dlg.GetName(); name.Replace( " ", "_" ); - wxString lib = getTargetLib(); - // Test if there is a component with this name already. if( !lib.empty() && m_libMgr->PartExists( name, lib ) ) {