From e5ff4f8582b3dc3a47ead29379c8e9fc6ebd3ab5 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 21 Sep 2018 19:07:54 -0400 Subject: [PATCH] Pcbnew: fix lock file bug on windows. The lock file code would reset the lock file every other time the same board file was opened in Pcbnew in the stand alone mode. This created the perfect toggle switch causing the board to be reloaded every other time the same board was selected. Please note that wxSingleInstanceChecker is broken on Linux and most likely MacOS as well due to a bug in wxWidgets. On these platforms, the already opened file is reopened rather than displaying a warning that the file is already opened. Fixes lp:1777599 https://bugs.launchpad.net/kicad/+bug/1777599 --- pcbnew/files.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 40946744a8..0a86ee1905 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -412,13 +413,17 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // We insist on caller sending us an absolute path, if it does not, we say it's a bug. wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) ); - if( !LockFile( fullFileName ) ) + std::unique_ptr lockFile = ::LockFile( fullFileName ); + + if( !lockFile ) { wxString msg = wxString::Format( _( "PCB file \"%s\" is already open." ), fullFileName ); DisplayError( this, msg ); return false; } + m_file_checker.reset( lockFile.release() ); + if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() ) { if( !HandleUnsavedChanges( this, _( "The current PCB has been modified. Save changes?" ),