Commit patch for bug 1116059 (Inconsistency between confirmation dialogs)
This commit is contained in:
parent
eed97c549d
commit
da757938e6
|
@ -285,7 +285,17 @@ void LIB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|||
}
|
||||
|
||||
|
||||
void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
||||
void LIB_EDIT_FRAME::OnSaveActiveLibrary( wxCommandEvent& event )
|
||||
{
|
||||
bool newFile = false;
|
||||
if( event.GetId() == ID_LIBEDIT_SAVE_CURRENT_LIB_AS )
|
||||
newFile = true;
|
||||
|
||||
this->SaveActiveLibrary( newFile );
|
||||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::SaveActiveLibrary( bool newFile )
|
||||
{
|
||||
wxFileName fn;
|
||||
wxString msg;
|
||||
|
@ -295,7 +305,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
if( m_library == NULL )
|
||||
{
|
||||
DisplayError( this, _( "No library specified." ) );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( GetScreen()->IsModify() )
|
||||
|
@ -304,7 +314,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
SaveOnePartInMemory();
|
||||
}
|
||||
|
||||
if( event.GetId() == ID_LIBEDIT_SAVE_CURRENT_LIB_AS )
|
||||
if( newFile )
|
||||
{ // Get a new name for the library
|
||||
wxString default_path = wxGetApp().ReturnLastVisitedLibraryPath();
|
||||
wxFileDialog dlg( this, _( "Component Library Name:" ), default_path,
|
||||
|
@ -312,7 +322,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return;
|
||||
return false;
|
||||
|
||||
fn = dlg.GetPath();
|
||||
|
||||
|
@ -330,12 +340,12 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
msg = _( "Modify library file \"" ) + fn.GetFullPath() + _( "\"?" );
|
||||
|
||||
if( !IsOK( this, msg ) )
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify the user has write privileges before attempting to save the library file.
|
||||
if( !IsWritable( fn ) )
|
||||
return;
|
||||
return false;
|
||||
|
||||
ClearMsgPanel();
|
||||
|
||||
|
@ -367,7 +377,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
msg = _( "Error occurred while saving library file \"" ) + fn.GetFullPath() + _( "\"." );
|
||||
AppendMsgPanel( _( "*** ERROR: ***" ), msg, RED );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch( ... /* IO_ERROR ioe */ )
|
||||
|
@ -375,7 +385,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
libFileName.MakeAbsolute();
|
||||
msg = wxT( "Failed to create component library file " ) + libFileName.GetFullPath();
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
wxFileName docFileName = libFileName;
|
||||
|
@ -407,7 +417,7 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
docFileName.GetFullPath() + _( "\"." );
|
||||
AppendMsgPanel( _( "*** ERROR: ***" ), msg, RED );
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch( ... /* IO_ERROR ioe */ )
|
||||
|
@ -416,13 +426,15 @@ void LIB_EDIT_FRAME::SaveActiveLibrary( wxCommandEvent& event )
|
|||
msg = wxT( "Failed to create component document library file " ) +
|
||||
docFileName.GetFullPath();
|
||||
DisplayError( this, msg );
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
msg = _( "Library file \"" ) + fn.GetFullName() + wxT( "\" Ok" );
|
||||
fn.SetExt( DOC_EXT );
|
||||
wxString msg1 = _( "Document file \"" ) + fn.GetFullPath() + wxT( "\" Ok" );
|
||||
AppendMsgPanel( msg, msg1, BLUE );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_ACTIVATE( LIB_EDIT_FRAME::OnActivate )
|
||||
|
||||
/* Main horizontal toolbar. */
|
||||
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::SaveActiveLibrary )
|
||||
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnSaveActiveLibrary )
|
||||
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
|
||||
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
|
||||
|
@ -130,7 +130,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
|
||||
/* menubar commands */
|
||||
EVT_MENU( wxID_EXIT, LIB_EDIT_FRAME::CloseWindow )
|
||||
EVT_MENU( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::SaveActiveLibrary )
|
||||
EVT_MENU( ID_LIBEDIT_SAVE_CURRENT_LIB_AS, LIB_EDIT_FRAME::OnSaveActiveLibrary )
|
||||
EVT_MENU( ID_LIBEDIT_GEN_PNG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
|
||||
EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
|
||||
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
||||
|
@ -343,15 +343,25 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
{
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
if( !IsOK( this, _( "Component was modified!\nDiscard changes?" ) ) )
|
||||
int ii = DisplayExitDialog( this, _( "Save the changes in the library before closing?" ) );
|
||||
|
||||
switch( ii )
|
||||
{
|
||||
case wxID_NO:
|
||||
break;
|
||||
|
||||
case wxID_OK:
|
||||
case wxID_YES:
|
||||
if ( this->SaveActiveLibrary( false ) )
|
||||
break;
|
||||
|
||||
// fall through: cancel the close because of an error
|
||||
|
||||
case wxID_CANCEL:
|
||||
Event.Veto();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetScreen()->ClrModify();
|
||||
}
|
||||
GetScreen()->ClrModify();
|
||||
}
|
||||
|
||||
BOOST_FOREACH( const CMP_LIBRARY &lib, CMP_LIBRARY::GetLibraryList() )
|
||||
|
|
|
@ -439,13 +439,24 @@ private:
|
|||
void SelectActiveLibrary( CMP_LIBRARY* aLibrary = NULL );
|
||||
|
||||
/**
|
||||
* Function SaveActiveLibrary
|
||||
* Function OnSaveActiveLibrary
|
||||
* it the command event handler to save the changes to the current library.
|
||||
*
|
||||
* A backup file of the current library is saved with the .bak extension before the
|
||||
* changes made to the library are saved.
|
||||
*/
|
||||
void SaveActiveLibrary( wxCommandEvent& event );
|
||||
void OnSaveActiveLibrary( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Function SaveActiveLibrary
|
||||
* saves the changes to the current library.
|
||||
*
|
||||
* A backup file of the current library is saved with the .bak extension before the
|
||||
* changes made to the library are saved.
|
||||
* @param newFile Ask for a new file name to save the library.
|
||||
* @return True if the library was successfully saved.
|
||||
*/
|
||||
bool SaveActiveLibrary( bool newFile );
|
||||
|
||||
/**
|
||||
* Function LoadComponentFromCurrentLib
|
||||
|
|
|
@ -320,12 +320,39 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
{
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
if( !IsOK( this, _( "Module Editor: Module modified! Continue?" ) ) )
|
||||
int ii = DisplayExitDialog( this, _( "Save the changes in the module before closing?" ) );
|
||||
|
||||
switch( ii )
|
||||
{
|
||||
Event.Veto(); return;
|
||||
case wxID_NO:
|
||||
break;
|
||||
|
||||
case wxID_OK:
|
||||
case wxID_YES:
|
||||
// code from FOOTPRINT_EDIT_FRAME::Process_Special_Functions,
|
||||
// at case ID_MODEDIT_SAVE_LIBMODULE
|
||||
if( GetBoard()->m_Modules && getLibPath() != wxEmptyString )
|
||||
{
|
||||
if( Save_Module_In_Library( getLibPath(), GetBoard()->m_Modules, true, true ))
|
||||
{
|
||||
// save was correct
|
||||
GetScreen()->ClrModify();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayError( this, _( "Library is not set, the module could not be saved." ) );
|
||||
}
|
||||
// fall through: cancel the close because of an error
|
||||
|
||||
case wxID_CANCEL:
|
||||
Event.Veto();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//close the editor
|
||||
SaveSettings();
|
||||
Destroy();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue