Commit dc978a9c authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Code cleaning and Fix a crash under wxWidgets 2.9.2 and Linux, related to wxFileHistory.

Coding policy fixes and dialog design rules cosmetic enhancement.
parents cf8f8ca2 d5dbb531
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -213,7 +213,6 @@ void EDA_BASE_FRAME::UpdateFileHistory( const wxString& FullFileName,
        fileHistory = & wxGetApp().m_fileHistory;
        fileHistory = & wxGetApp().m_fileHistory;


    fileHistory->AddFileToHistory( FullFileName );
    fileHistory->AddFileToHistory( FullFileName );
    ReCreateMenuBar();
}
}




@@ -245,7 +244,6 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
            DisplayError( this, msg );
            DisplayError( this, msg );
            fileHistory->RemoveFileFromHistory( i );
            fileHistory->RemoveFileFromHistory( i );
            fn = wxEmptyString;
            fn = wxEmptyString;
            ReCreateMenuBar();
        }
        }
    }
    }


+1 −5
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
              CVPCB_MAINFRAME::SaveQuitCvpcb )
              CVPCB_MAINFRAME::SaveQuitCvpcb )
    EVT_MENU( wxID_EXIT,
    EVT_MENU( wxID_EXIT,
              CVPCB_MAINFRAME::OnQuit )
              CVPCB_MAINFRAME::OnQuit )
    EVT_MENU( ID_GENERAL_HELP,
    EVT_MENU( wxID_HELP,
              CVPCB_MAINFRAME::GetKicadHelp )
              CVPCB_MAINFRAME::GetKicadHelp )
    EVT_MENU( wxID_ABOUT,
    EVT_MENU( wxID_ABOUT,
              CVPCB_MAINFRAME::GetKicadAbout )
              CVPCB_MAINFRAME::GetKicadAbout )
@@ -461,8 +461,6 @@ void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )


    if( ReadNetList() )
    if( ReadNetList() )
    {
    {
        UpdateFileHistory( m_NetlistFileName.GetFullPath() );

        SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
        SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
                  wxT( " " ) + m_NetlistFileName.GetFullPath() );
                  wxT( " " ) + m_NetlistFileName.GetFullPath() );
    }
    }
@@ -470,8 +468,6 @@ void CVPCB_MAINFRAME::LoadNetList( wxCommandEvent& event )
    {
    {
        SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
        SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
    }
    }

    ReCreateMenuBar();
}
}




+0 −5
Original line number Original line Diff line number Diff line
@@ -60,8 +60,6 @@ void WinEDA_App::MacOpenFile(const wxString &fileName)


    if( frame->ReadNetList() )
    if( frame->ReadNetList() )
    {
    {
        frame->UpdateFileHistory( filename.GetFullPath() );

        frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
        frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
                  wxT( " " ) + filename.GetFullPath() );
                  wxT( " " ) + filename.GetFullPath() );
    }
    }
@@ -69,9 +67,6 @@ void WinEDA_App::MacOpenFile(const wxString &fileName)
    {
    {
        frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
        frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
    }
    }

    frame->ReCreateMenuBar();

}
}


// Create a new application object
// Create a new application object
+3 −0
Original line number Original line Diff line number Diff line
@@ -115,6 +115,9 @@ bool CVPCB_MAINFRAME::ReadNetList()
    /* Update the title of the main window. */
    /* Update the title of the main window. */
    SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
    SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
              wxT( " " ) + m_NetlistFileName.GetFullPath() );
              wxT( " " ) + m_NetlistFileName.GetFullPath() );

    UpdateFileHistory( m_NetlistFileName.GetFullPath() );

    return true;
    return true;
}
}


+11 −5
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
    wxMenuItem* item;
    wxMenuItem* item;
    wxMenuBar*  menuBar = GetMenuBar();
    wxMenuBar*  menuBar = GetMenuBar();


    if( ! menuBar )
    if( ! menuBar )     // Delete all menus
        menuBar = new wxMenuBar();
        menuBar = new wxMenuBar();


    // Delete all existing menus so they can be rebuilt.
    // Delete all existing menus so they can be rebuilt.
@@ -45,8 +45,14 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
                            open_document_xpm );
                            open_document_xpm );


    // Open Recent submenu
    // Open Recent submenu
    wxMenu* openRecentMenu = new wxMenu();
    static wxMenu* openRecentMenu;
    wxGetApp().m_fileHistory.AddFilesToMenu( openRecentMenu );
    // Add this menu to list menu managed by m_fileHistory
    // (the file history will be updated when adding/removing files in history
    if( openRecentMenu )
        wxGetApp().m_fileHistory.RemoveMenu( openRecentMenu );
    openRecentMenu = new wxMenu();
    wxGetApp().m_fileHistory.UseMenu( openRecentMenu );
    wxGetApp().m_fileHistory.AddFilesToMenu( );
    ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1,
    ADD_MENUITEM_WITH_HELP_AND_SUBMENU( filesMenu, openRecentMenu, -1,
                                        _( "Open &Recent" ),
                                        _( "Open &Recent" ),
                                        _("Open a recent opened netlist document" ),
                                        _("Open a recent opened netlist document" ),
@@ -111,8 +117,8 @@ void CVPCB_MAINFRAME::ReCreateMenuBar()
    AddHelpVersionInfoMenuEntry( helpMenu );
    AddHelpVersionInfoMenuEntry( helpMenu );


    // Contents
    // Contents
    ADD_MENUITEM_WITH_HELP( helpMenu, ID_GENERAL_HELP, _( "&Contents" ),
    ADD_MENUITEM_WITH_HELP( helpMenu, wxID_HELP, _( "&Contents" ),
                           _( "Open the cvpcb manual" ),
                           _( "Open the Cvpcb handbook" ),
                            online_help_xpm );
                            online_help_xpm );


    // About
    // About
Loading