Commit 0b69ed3a authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Fix Eeschema sheet issues. Should close out bug lp:593782

* Refresh canvas when user cancels edits so that the discarded sheet is
  cleared from the schematic.
* Add file name validation to the sheet properties dialog to prevent
  illegal file name characters from being entered into the text control.
* Rename FOOTPRINT_NAME_VALIDATOR to FILE_NAME_CHAR_VALIDATOR for clarity.
parent 27b9d013
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
#include <validators.h>


FOOTPRINT_NAME_VALIDATOR::FOOTPRINT_NAME_VALIDATOR( wxString* aValue ) :
FILE_NAME_CHAR_VALIDATOR::FILE_NAME_CHAR_VALIDATOR( wxString* aValue ) :
    wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
{
    // The Windows (DOS) file system forbidden characters already include the forbidden
+5 −0
Original line number Diff line number Diff line
#include <wx/string.h>
#include <dialog_sch_sheet_props.h>
#include <validators.h>


DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) :
    DIALOG_SCH_SHEET_PROPS_BASE( parent )
{
    m_textFileName->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
    m_textFileName->SetFocus();
    m_sdbSizer1OK->SetDefault();
}


void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName )
{
    // Filenames are stored using unix notation
@@ -18,6 +22,7 @@ void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName )
    m_textFileName->SetValue( fname );
}


const wxString DIALOG_SCH_SHEET_PROPS::GetFileName()
{
    // Filenames are stored using unix notation
+15 −2
Original line number Diff line number Diff line
@@ -75,6 +75,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
    if( !fileName.IsOk() )
    {
        DisplayError( this, _( "File name is not valid!" ) );

        if( m_canvas )
            m_canvas->Refresh();

        return false;
    }

@@ -85,6 +89,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
    {
        DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
                                              GetChars( dlg.GetSheetName() ) ) );

        if( m_canvas )
            m_canvas->Refresh();

        return false;
    }

@@ -121,8 +129,13 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
            msg += _("\n\nDo you want to create a sheet with the contents of this file?" );

            if( !IsOK( this, msg ) )
            {
                if( m_canvas )
                    m_canvas->Refresh();

                return false;
            }
        }
        else                                                   // New file.
        {
            aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
+3 −3
Original line number Diff line number Diff line
@@ -30,16 +30,16 @@
#include <wx/valtext.h>

/**
 * Class FOOTPRINT_NAME_VALIDATOR
 * Class FILE_NAME_CHAR_VALIDATOR
 *
 * This class provides a custom wxValidator object for limiting the allowable characters when
 * defining footprint names.  Since the introduction of the PRETTY footprint library format,
 * footprint names cannot have any characters that would prevent file creation on any platform.
 */
class FOOTPRINT_NAME_VALIDATOR : public wxTextValidator
class FILE_NAME_CHAR_VALIDATOR : public wxTextValidator
{
public:
    FOOTPRINT_NAME_VALIDATOR( wxString* aValue = NULL ) :
    FILE_NAME_CHAR_VALIDATOR( wxString* aValue = NULL ) :
        wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
    {
        // The Windows (DOS) file system forbidden characters already include the forbidden
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME*
    icon.CopyFromBitmap( KiBitmap( icon_modedit_xpm ) );
    SetIcon( icon );

    m_FootprintNameCtrl->SetValidator( FOOTPRINT_NAME_VALIDATOR() );
    m_FootprintNameCtrl->SetValidator( FILE_NAME_CHAR_VALIDATOR() );
    initModeditProperties();
    m_sdbSizerStdButtonsOK->SetDefault();
    GetSizer()->SetSizeHints( this );
Loading