Disable the wxFileSystemWatcher on network shares

Fix #5740
Fix #4126

This is a stupid solution because SAMBA sends invalid events and wxWidgets decides to assert rather than ignore them.
Why can't people just use Windows Server shares :(
This commit is contained in:
Marek Roszko 2020-12-14 20:01:41 -05:00
parent 4100650ce1
commit f168ece461
2 changed files with 27 additions and 1 deletions

View File

@ -65,6 +65,10 @@ if( UNIX )
)
endif()
if( WIN32 )
list( APPEND EXTRA_KICAD_LIBS "Shlwapi" )
endif()
if( APPLE )
set_target_properties( kicad PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/kicad/Info.plist
@ -79,6 +83,7 @@ else()
gal
${wxWidgets_LIBRARIES}
${GDI_PLUS_LIBRARIES}
${EXTRA_KICAD_LIBS}
)
endif()

View File

@ -47,6 +47,9 @@
#include "tree_project_frame.h"
#if defined(_WIN32)
#include <shlwapi.h>
#endif
/* Note about the tree project build process:
* Building the tree project can be *very* long if there are a lot of subdirectories
@ -1065,7 +1068,26 @@ void TREE_PROJECT_FRAME::OnFileSystemEvent( wxFileSystemWatcherEvent& event )
void TREE_PROJECT_FRAME::FileWatcherReset()
{
wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
// Prepare file watcher:
#ifdef _WIN32
if( PathIsNetworkPathW( prj_dir.wc_str() ) )
{
// Don't support network shares for now
// SAMBA passes bad events to Windows and wxWidgets idiotically asserts
// rather than accepting vlaid event IDs
// Windows Server shares do not have this problem
m_Parent->SetStatusText( _( "Project on network share, auto refresh not available" ), 0 );
return;
}
else
{
m_Parent->SetStatusText( _( "" ), 0 );
}
#endif
if( m_watcher )
{
m_watcher->RemoveAll();
@ -1084,7 +1106,6 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
// moreover, under wxWidgets 2.9.4, AddTree does not work properly.
// We can see wxString under a debugger, not a wxFileName
wxString prj_dir = wxPathOnly( m_Parent->GetProjectFileName() );
wxFileName fn;
fn.AssignDir( prj_dir );
fn.DontFollowLink();