Commit 5436798e authored by jean-pierre charras's avatar jean-pierre charras

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

parent 2fc643de
...@@ -532,13 +532,6 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event ) ...@@ -532,13 +532,6 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
tmp << wxT( "OFF\n" ); tmp << wxT( "OFF\n" );
#endif #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=" ); tmp << wxT( " KICAD_SCRIPTING=" );
#ifdef KICAD_SCRIPTING #ifdef KICAD_SCRIPTING
tmp << wxT( "ON\n" ); tmp << wxT( "ON\n" );
......
...@@ -183,7 +183,6 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, ...@@ -183,7 +183,6 @@ public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
void SaveSettings(); void SaveSettings();
#ifdef KICAD_USE_FILES_WATCHER #ifdef KICAD_USE_FILES_WATCHER
void FileWatcherReset();
/** /**
* Called by sending a event with id = ID_INIT_WATCHED_PATHS * Called by sending a event with id = ID_INIT_WATCHED_PATHS
* rebuild the list of wahtched paths * rebuild the list of wahtched paths
......
...@@ -595,7 +595,8 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName, ...@@ -595,7 +595,8 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
addFile = false; addFile = false;
// check the first 100 lines for the "Sheet 1" string // 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 ) ) if( !fgets( line, sizeof(line), fp ) )
break; break;
...@@ -968,7 +969,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event ) ...@@ -968,7 +969,7 @@ void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
{ {
#ifdef KICAD_USE_FILES_WATCHER #ifdef KICAD_USE_FILES_WATCHER
#ifndef __WINDOWS__ #ifndef __WINDOWS__
m_TreeProject->FileWatcherReset(); FileWatcherReset();
#endif #endif
#endif #endif
} }
...@@ -1066,6 +1067,9 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir ) ...@@ -1066,6 +1067,9 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
*/ */
void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event ) void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
{ {
wxFileName pathModified = event.GetPath();
wxString subdir = pathModified.GetPath();
wxString fn = pathModified.GetFullPath();
switch( event.GetChangeType() ) switch( event.GetChangeType() )
{ {
...@@ -1084,50 +1088,53 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir ) ...@@ -1084,50 +1088,53 @@ wxTreeItemId TREE_PROJECT_FRAME::findSubdirTreeItem( const wxString& aSubDir )
return; return;
} }
wxFileName pathModified = event.GetPath();
wxString subdir = pathModified.GetPath();
wxString fn = pathModified.GetFullPath();
wxTreeItemId root_id = findSubdirTreeItem( subdir ); wxTreeItemId root_id = findSubdirTreeItem( subdir );
if( !root_id.IsOk() ) if( !root_id.IsOk() )
return; 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() wxTreeItemIdValue cookie; // dummy variable needed by GetFirstChild()
wxTreeItemId kid = m_TreeProject->GetFirstChild( root_id, cookie ); 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() ) while( kid.IsOk() )
{ {
TREEPROJECT_ITEM* itemData = GetItemIdData( kid ); TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
if( itemData && ( itemData->m_FileName == fn ) ) if( itemData && ( itemData->m_FileName == fn ) )
{ {
if( event.GetChangeType() == wxFSW_EVENT_DELETE )
m_TreeProject->Delete( kid ); m_TreeProject->Delete( kid );
else return;
}
kid = m_TreeProject->GetNextChild( root_id, cookie );
}
break;
case wxFSW_EVENT_RENAME :
{ {
wxFileName newpath = event.GetNewPath(); wxFileName newpath = event.GetNewPath();
wxString newfn = newpath.GetFullPath(); wxString newfn = newpath.GetFullPath();
// Change item label and item data while( kid.IsOk() )
// Extension could be modified and be not an usually selected file type {
// However, here we do not filter files. TREEPROJECT_ITEM* itemData = GetItemIdData( kid );
// This is simple, and I am not sure filtering renamed files here is better,
// because they could disappear, like deleted files if( itemData && ( itemData->m_FileName == fn ) )
itemData->SetFileName( newpath.GetFullPath() ); {
m_TreeProject->SetItemText( kid, newpath.GetFullName() ); m_TreeProject->Delete( kid );
} break;
return;
} }
kid = m_TreeProject->GetNextChild( root_id, cookie ); kid = m_TreeProject->GetNextChild( root_id, cookie );
} }
AddItemToTreeProject( newfn, root_id, false );
}
break;
} }
/* Sort filenames by alphabetic order */ /* Sort filenames by alphabetic order */
......
...@@ -123,8 +123,6 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -123,8 +123,6 @@ MODULE::MODULE( const MODULE& aModule ) :
} }
// Copy auxiliary data: Drawings // Copy auxiliary data: Drawings
// m_Drawings.DeleteAll();
for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() )
{ {
BOARD_ITEM* newItem; BOARD_ITEM* newItem;
...@@ -145,8 +143,6 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -145,8 +143,6 @@ MODULE::MODULE( const MODULE& aModule ) :
} }
// Copy auxiliary data: 3D_Drawings info // Copy auxiliary data: 3D_Drawings info
// m_3D_Drawings.DeleteAll();
for( S3D_MASTER* item = aModule.m_3D_Drawings; item; item = item->Next() ) for( S3D_MASTER* item = aModule.m_3D_Drawings; item; item = item->Next() )
{ {
if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes. if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes.
...@@ -165,6 +161,9 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -165,6 +161,9 @@ MODULE::MODULE( const MODULE& aModule ) :
m_Doc = aModule.m_Doc; m_Doc = aModule.m_Doc;
m_KeyWord = aModule.m_KeyWord; m_KeyWord = aModule.m_KeyWord;
// Ensure auxiliary data is up to date
CalculateBoundingBox();
} }
...@@ -294,6 +293,9 @@ void MODULE::Copy( MODULE* aModule ) ...@@ -294,6 +293,9 @@ void MODULE::Copy( MODULE* aModule )
m_Doc = aModule->m_Doc; m_Doc = aModule->m_Doc;
m_KeyWord = aModule->m_KeyWord; m_KeyWord = aModule->m_KeyWord;
// Ensure auxiliary data is up to date
CalculateBoundingBox();
} }
...@@ -400,7 +402,7 @@ EDA_RECT MODULE::GetFootPrintRect() const ...@@ -400,7 +402,7 @@ EDA_RECT MODULE::GetFootPrintRect() const
area.SetOrigin( m_Pos ); area.SetOrigin( m_Pos );
area.SetEnd( 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() ) for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
if( edge->Type() == PCB_MODULE_EDGE_T ) if( edge->Type() == PCB_MODULE_EDGE_T )
......
...@@ -54,18 +54,12 @@ ...@@ -54,18 +54,12 @@
#include <fctsys.h> #include <fctsys.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h> #include <confirm.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <wxPcbStruct.h>
#include <richio.h> #include <richio.h>
#include <dialog_helpers.h> #include <dialog_helpers.h>
#include <macros.h>
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <dialog_netlist.h> #include <dialog_netlist.h>
#include <netlist_reader.h> #include <netlist_reader.h>
#include <algorithm> #include <algorithm>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment