Kicad, project_tree_pane.cpp: fix regression, round 2.

(directories visible in project tree were not populated).
This commit is contained in:
jean-pierre charras 2021-01-08 17:40:29 +01:00
parent f1fdf8d6d1
commit f5b4bc5bfe
2 changed files with 20 additions and 10 deletions

View File

@ -141,6 +141,7 @@ PROJECT_TREE_PANE::PROJECT_TREE_PANE( KICAD_MANAGER_FRAME* parent ) :
m_TreeProject = NULL;
m_isRenaming = false;
m_selectedItem = nullptr;
m_watcherNeedReset = false;
m_watcher = NULL;
Connect( wxEVT_FSWATCHER,
@ -514,7 +515,7 @@ wxTreeItemId PROJECT_TREE_PANE::addItemToProjectTree( const wxString& aName,
#ifndef __WINDOWS__
if( subdir_populated )
FileWatcherReset();
m_watcherNeedReset = true;
#endif
return newItemId;
@ -584,11 +585,9 @@ void PROJECT_TREE_PANE::ReCreateTreePrj()
if( filename != fn.GetFullName() )
{
wxString name = dir.GetName() + wxFileName::GetPathSeparator() + filename;
// Add items living in the project directory, and do not populate the item
// Add items living in the project directory, and populate the item
// if it is a directory (sub directories will be not populated)
// (Populate the directory is better but creates wxWidgets alerts in debug
// mode)
addItemToProjectTree( name, m_root, &projects, false );
addItemToProjectTree( name, m_root, &projects, true );
}
haveFile = dir.GetNext( &filename );
@ -910,6 +909,12 @@ void PROJECT_TREE_PANE::onIdle( wxIdleEvent& aEvent )
{
// Idle executes once all other events finished processing. This makes it ideal to launch
// a new window without starting Focus wars.
if( m_watcherNeedReset )
{
m_selectedItem = nullptr;
FileWatcherReset();
}
if( m_selectedItem != nullptr )
{
// Activate launches a window which may run the event loop on top of us and cause OnIdle
@ -981,7 +986,7 @@ void PROJECT_TREE_PANE::onExpand( wxTreeEvent& Event )
#ifndef __WINDOWS__
if( subdir_populated )
FileWatcherReset();
m_watcherNeedReset = true;
#endif
}
@ -1173,6 +1178,8 @@ void PROJECT_TREE_PANE::onFileSystemEvent( wxFileSystemWatcherEvent& event )
void PROJECT_TREE_PANE::FileWatcherReset()
{
m_watcherNeedReset = false;
wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
#if defined( _WIN32 )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -62,7 +62,7 @@ public:
* Reinit the watched paths
* Should be called after opening a new project to
* rebuild the list of watched paths.
* Should be called *atfer* the main loop event handler is started
* Should be called *after* the main loop event handler is started
*/
void FileWatcherReset();
@ -188,11 +188,14 @@ public:
PROJECT_TREE* m_TreeProject;
private:
bool m_isRenaming; // Are we in the process of renaming a file
bool m_isRenaming; // Are we in the process of renaming a file
wxTreeItemId m_root;
std::vector<wxString> m_filters;
wxFileSystemWatcher* m_watcher; // file system watcher
wxFileSystemWatcher* m_watcher; // file system watcher
PROJECT_TREE_ITEM* m_selectedItem;
bool m_watcherNeedReset; // true if FileWatcherReset() must be called
// (during an idle time for instance) after
// the main loop event handler is started
DECLARE_EVENT_TABLE()
};