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
This commit is contained in:
parent
969e85daa3
commit
e5ff4f8582
|
@ -45,6 +45,7 @@
|
||||||
#include <kiway.h>
|
#include <kiway.h>
|
||||||
#include <kiway_player.h>
|
#include <kiway_player.h>
|
||||||
#include <trace_helpers.h>
|
#include <trace_helpers.h>
|
||||||
|
#include <lockfile.cpp>
|
||||||
|
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
|
@ -412,13 +413,17 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
// We insist on caller sending us an absolute path, if it does not, we say it's a bug.
|
// 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!" ) );
|
wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "Path is not absolute!" ) );
|
||||||
|
|
||||||
if( !LockFile( fullFileName ) )
|
std::unique_ptr<wxSingleInstanceChecker> lockFile = ::LockFile( fullFileName );
|
||||||
|
|
||||||
|
if( !lockFile )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "PCB file \"%s\" is already open." ), fullFileName );
|
wxString msg = wxString::Format( _( "PCB file \"%s\" is already open." ), fullFileName );
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_file_checker.reset( lockFile.release() );
|
||||||
|
|
||||||
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
|
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
|
||||||
{
|
{
|
||||||
if( !HandleUnsavedChanges( this, _( "The current PCB has been modified. Save changes?" ),
|
if( !HandleUnsavedChanges( this, _( "The current PCB has been modified. Save changes?" ),
|
||||||
|
|
Loading…
Reference in New Issue