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

Kicad: Fix a compil issue under Linux, and minor code cleaning, about wxFileWatcher

parents 2fc643de 5436798e
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -532,13 +532,6 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
    tmp << wxT( "OFF\n" );
#endif

    tmp << wxT( "         USE_BOOST_POLYGON_LIBRARY=" );
#ifdef USE_BOOST_POLYGON_LIBRARY
    tmp << wxT( "ON\n" );
#else
    tmp << wxT( "OFF\n" );
#endif

    tmp << wxT( "         KICAD_SCRIPTING=" );
#ifdef KICAD_SCRIPTING
    tmp << wxT( "ON\n" );
+0 −1
Original line number Diff line number Diff line
@@ -183,7 +183,6 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
    void SaveSettings();

#ifdef KICAD_USE_FILES_WATCHER
    void                            FileWatcherReset();
    /**
     * Called by sending a event with id = ID_INIT_WATCHED_PATHS
     * rebuild the list of wahtched paths
+39 −32
Original line number Diff line number Diff line
@@ -595,7 +595,8 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
            addFile = false;

            // check the first 100 lines for the "Sheet 1" string
            for( int i = 0; i<100; ++i )
            int l =0;
            for( int i = 0; i<100; ++i, l++ )
            {
                if( !fgets( line, sizeof(line), fp ) )
                    break;
@@ -968,7 +969,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
    {
#ifdef KICAD_USE_FILES_WATCHER
    #ifndef __WINDOWS__
        m_TreeProject->FileWatcherReset();
        FileWatcherReset();
    #endif
#endif
    }
@@ -1066,6 +1067,9 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
 */
 void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
{
    wxFileName pathModified = event.GetPath();
    wxString subdir = pathModified.GetPath();
    wxString fn = pathModified.GetFullPath();

    switch( event.GetChangeType() )
    {
@@ -1084,50 +1088,53 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
        return;
    }

    wxFileName pathModified = event.GetPath();
    wxString subdir = pathModified.GetPath();
    wxString fn = pathModified.GetFullPath();

    wxTreeItemId root_id = findSubdirTreeItem( subdir );
    if( !root_id.IsOk() )
        return;

    // Add item if it is created
    if( event.GetChangeType() == wxFSW_EVENT_CREATE )
        AddItemToTreeProject( pathModified.GetFullPath(), root_id, false );

    // search for item to delete/rename.
    if( event.GetChangeType() == wxFSW_EVENT_DELETE ||
        event.GetChangeType() == wxFSW_EVENT_RENAME )
    {
    wxTreeItemIdValue  cookie;  // dummy variable needed by GetFirstChild()
    wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie );

    switch( event.GetChangeType() )
    {
        case wxFSW_EVENT_CREATE:
            AddItemToTreeProject( pathModified.GetFullPath(), root_id, false );
            break;

        case wxFSW_EVENT_DELETE:
            while( kid.IsOk() )
            {
                TREEPROJECT_ITEM* itemData = GetItemIdData( kid );

                if( itemData && ( itemData->m_FileName == fn ) )
                {
                if( event.GetChangeType() == wxFSW_EVENT_DELETE )
                    m_TreeProject->Delete( kid );
                else
                    return;
                }
                kid = m_TreeProject->GetNextChild( root_id, cookie );
            }
            break;

        case wxFSW_EVENT_RENAME :
        {
            wxFileName newpath = event.GetNewPath();
            wxString newfn = newpath.GetFullPath();
                    // Change item label and item data
                    // Extension could be modified and be not an usually selected file type
                    // However, here we do not filter files.
                    // This is simple, and I am not sure filtering renamed files here is better,
                    // because they could disappear, like deleted files
                    itemData->SetFileName( newpath.GetFullPath() );
                    m_TreeProject->SetItemText( kid, newpath.GetFullName() );
                }
                return;
            while( kid.IsOk() )
            {
                TREEPROJECT_ITEM* itemData = GetItemIdData( kid );

                if( itemData && ( itemData->m_FileName == fn ) )
                {
                    m_TreeProject->Delete( kid );
                    break;
                }

                kid = m_TreeProject->GetNextChild( root_id, cookie );
            }
            AddItemToTreeProject( newfn, root_id, false );
        }
            break;
    }

    /* Sort filenames by alphabetic order */
+7 −5
Original line number Diff line number Diff line
@@ -123,8 +123,6 @@ MODULE::MODULE( const MODULE& aModule ) :
    }

    // Copy auxiliary data: Drawings
    // m_Drawings.DeleteAll();

    for( BOARD_ITEM* item = aModule.m_Drawings;  item;  item = item->Next() )
    {
        BOARD_ITEM* newItem;
@@ -145,8 +143,6 @@ MODULE::MODULE( const MODULE& aModule ) :
    }

    // Copy auxiliary data: 3D_Drawings info
    // m_3D_Drawings.DeleteAll();

    for( S3D_MASTER* item = aModule.m_3D_Drawings;  item;  item = item->Next() )
    {
        if( item->m_Shape3DName.IsEmpty() )           // do not copy empty shapes.
@@ -165,6 +161,9 @@ MODULE::MODULE( const MODULE& aModule ) :

    m_Doc     = aModule.m_Doc;
    m_KeyWord = aModule.m_KeyWord;

    // Ensure auxiliary data is up to date
    CalculateBoundingBox();
}


@@ -294,6 +293,9 @@ void MODULE::Copy( MODULE* aModule )

    m_Doc     = aModule->m_Doc;
    m_KeyWord = aModule->m_KeyWord;

    // Ensure auxiliary data is up to date
    CalculateBoundingBox();
}


@@ -400,7 +402,7 @@ EDA_RECT MODULE::GetFootPrintRect() const

    area.SetOrigin( m_Pos );
    area.SetEnd( m_Pos );
    area.Inflate( 50 );       // Give a min size
    area.Inflate( Millimeter2iu( 0.25 ) );   // Give a min size to the area

    for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
        if( edge->Type() == PCB_MODULE_EDGE_T )
+0 −6
Original line number Diff line number Diff line
@@ -54,18 +54,12 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <wxPcbStruct.h>
#include <richio.h>
#include <dialog_helpers.h>
#include <macros.h>

#include <class_board.h>
#include <class_module.h>
#include <pcbnew.h>
#include <dialog_netlist.h>

#include <netlist_reader.h>

#include <algorithm>