From 0f89576f72b3e832cfe7c48a2e305785a617e143 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 8 Apr 2016 09:05:07 -0400 Subject: [PATCH] Eeschema: fix wxFileDialog assertion when importing component. (fixes lp:1558486) * wxFileDialog ctor was setting the file name using the most recently used path which was incorrect. Set the file path parameter to the most recently used path and the file name parameter to an empty string. * Remove last used import path and use the application wide most recently path instead. * Remove last used export path and use the application wide most recently path instead. --- eeschema/eeschema_config.cpp | 7 ------- eeschema/lib_export.cpp | 18 ++++++++---------- eeschema/libeditframe.h | 3 --- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index f21b6df264..7c744b34c8 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -743,11 +743,6 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) SetGridColor( GetLayerColor( LAYER_GRID ) ); SetDrawBgColor( GetLayerColor( LAYER_BACKGROUND ) ); - wxString pro_dir = Prj().GetProjectFullName(); - - m_lastLibExportPath = aCfg->Read( lastLibExportPathEntry, pro_dir ); - m_lastLibImportPath = aCfg->Read( lastLibImportPathEntry, pro_dir ); - SetDefaultLineThickness( aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) ); SetDefaultPinLength( aCfg->Read( DefaultPinLengthEntry, DEFAULTPINLENGTH ) ); m_textPinNumDefaultSize = aCfg->Read( defaultPinNumSizeEntry, DEFAULTPINNUMSIZE ); @@ -765,8 +760,6 @@ void LIB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::SaveSettings( aCfg ); - aCfg->Write( lastLibExportPathEntry, m_lastLibExportPath ); - aCfg->Write( lastLibImportPathEntry, m_lastLibImportPath ); aCfg->Write( DefaultPinLengthEntry, (long) GetDefaultPinLength() ); aCfg->Write( defaultPinNumSizeEntry, (long) GetPinNumDefaultSize() ); aCfg->Write( defaultPinNameSizeEntry, (long) GetPinNameDefaultSize() ); diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index f80abf517d..ab74805d56 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -2,8 +2,8 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2008-2016 Wayne Stambaugh + * Copyright (C) 2004-2016 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -48,8 +48,8 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) { m_lastDrawItem = NULL; - wxFileDialog dlg( this, _( "Import Component" ), m_lastLibImportPath, - m_mruPath, SchematicLibraryFileWildcard, + wxFileDialog dlg( this, _( "Import Component" ), m_mruPath, + wxEmptyString, SchematicLibraryFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) @@ -92,11 +92,9 @@ void LIB_EDIT_FRAME::OnImportPart( wxCommandEvent& event ) if( LoadOneLibraryPartAux( entry, lib.get() ) ) { - fn = dlg.GetPath(); - m_lastLibImportPath = fn.GetPath(); DisplayLibInfos(); GetScreen()->ClearUndoRedoList(); - m_canvas->Refresh(); + Zoom_Automatique( false ); } } @@ -120,8 +118,8 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) title = createLib ? _( "New Library" ) : _( "Export Component" ); - wxFileDialog dlg( this, title, m_lastLibExportPath, fn.GetFullName(), - SchematicLibraryFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); + wxFileDialog dlg( this, title, m_mruPath, fn.GetFullName(), + SchematicLibraryFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return; @@ -167,7 +165,7 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) } if( result ) - m_lastLibExportPath = fn.GetPath(); + m_mruPath = fn.GetPath(); if( result ) { diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 06c4169acd..dd8caac186 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -56,9 +56,6 @@ class LIB_EDIT_FRAME : public SCH_BASE_FRAME wxComboBox* m_partSelectBox; ///< a Box to select a part to edit (if any) wxComboBox* m_aliasSelectBox; ///< a box to select the alias to edit (if any) - wxString m_lastLibImportPath; - wxString m_lastLibExportPath; - /** Convert of the item currently being drawn. */ bool m_drawSpecificConvert;