Loading common/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ set( COMMON_SRCS kiway_express.cpp kiway_holder.cpp kiway_player.cpp lockfile.cpp msgpanel.cpp netlist_keywords.cpp newstroke_font.cpp Loading common/draw_frame.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include <math/box2.h> #include <wx/fontdlg.h> #include <wx/snglinst.h> #include <view/view.h> #include <view/view_controls.h> #include <gal/graphics_abstraction_layer.h> Loading Loading @@ -97,6 +98,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, long aStyle, const wxString & aFrameName ) : KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ) { m_file_checker = NULL; m_drawToolBar = NULL; m_optionsToolBar = NULL; m_gridSelectBox = NULL; Loading Loading @@ -179,6 +182,25 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME() m_currentScreen = NULL; m_auimgr.UnInit(); ReleaseFile(); } void EDA_DRAW_FRAME::ReleaseFile() { delete m_file_checker; m_file_checker = 0; } bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName ) { delete m_file_checker; m_file_checker = ::LockFile( aFileName ); return bool( m_file_checker ); } Loading common/lockfile.cpp 0 → 100644 +32 −0 Original line number Diff line number Diff line #include <wx/filename.h> #include <wx/snglinst.h> wxSingleInstanceChecker* LockFile( const wxString& aFileName ) { // first make absolute and normalize, to avoid that different lock files // for the same file can be created wxFileName fn( aFileName ); fn.MakeAbsolute(); wxString lockFileName = fn.GetFullPath() + wxT( ".lock" ); lockFileName.Replace( wxT( "/" ), wxT( "_" ) ); // We can have filenames coming from Windows, so also convert Windows separator lockFileName.Replace( wxT( "\\" ), wxT( "_" ) ); wxSingleInstanceChecker* p = new wxSingleInstanceChecker( lockFileName ); if( p->IsAnotherRunning() ) { delete p; p = NULL; } return p; } common/pgm_base.cpp +0 −44 Original line number Diff line number Diff line Loading @@ -262,7 +262,6 @@ static LANGUAGE_DESCR s_Languages[] = PGM_BASE::PGM_BASE() { m_pgm_checker = NULL; m_file_checker = NULL; m_locale = NULL; m_common_settings = NULL; Loading Loading @@ -290,20 +289,10 @@ void PGM_BASE::destroy() delete m_pgm_checker; m_pgm_checker = 0; delete m_file_checker; m_file_checker = 0; delete m_locale; m_locale = 0; } void PGM_BASE::ReleaseFile() { // Release the current file marked in use. delete m_file_checker; m_file_checker = 0; } void PGM_BASE::SetEditorName( const wxString& aFileName ) { Loading Loading @@ -677,36 +666,3 @@ void PGM_BASE::AddMenuLanguageList( wxMenu* MasterMenu ) } } bool PGM_BASE::LockFile( const wxString& aFileName ) { // first make absolute and normalize, to avoid that different lock files // for the same file can be created wxFileName fn( aFileName ); fn.MakeAbsolute(); // semaphore to protect the edition of the file by more than one instance if( m_file_checker != NULL ) { // it means that we had an open file and we are opening a different one delete m_file_checker; } wxString lockFileName = fn.GetFullPath() + wxT( ".lock" ); lockFileName.Replace( wxT( "/" ), wxT( "_" ) ); // We can have filenames coming from Windows, so also convert Windows separator lockFileName.Replace( wxT( "\\" ), wxT( "_" ) ); m_file_checker = new wxSingleInstanceChecker( lockFileName ); if( m_file_checker && m_file_checker->IsAnotherRunning() ) { return false; } return true; } eeschema/files-io.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "bug in single_top.cpp or project manager." ) ); if( !Pgm().LockFile( fullFileName ) ) if( !LockFile( fullFileName ) ) { wxString msg = wxString::Format( _( "Schematic file '%s' is already open." ), Loading Loading
common/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ set( COMMON_SRCS kiway_express.cpp kiway_holder.cpp kiway_player.cpp lockfile.cpp msgpanel.cpp netlist_keywords.cpp newstroke_font.cpp Loading
common/draw_frame.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include <math/box2.h> #include <wx/fontdlg.h> #include <wx/snglinst.h> #include <view/view.h> #include <view/view_controls.h> #include <gal/graphics_abstraction_layer.h> Loading Loading @@ -97,6 +98,8 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, long aStyle, const wxString & aFrameName ) : KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ) { m_file_checker = NULL; m_drawToolBar = NULL; m_optionsToolBar = NULL; m_gridSelectBox = NULL; Loading Loading @@ -179,6 +182,25 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME() m_currentScreen = NULL; m_auimgr.UnInit(); ReleaseFile(); } void EDA_DRAW_FRAME::ReleaseFile() { delete m_file_checker; m_file_checker = 0; } bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName ) { delete m_file_checker; m_file_checker = ::LockFile( aFileName ); return bool( m_file_checker ); } Loading
common/lockfile.cpp 0 → 100644 +32 −0 Original line number Diff line number Diff line #include <wx/filename.h> #include <wx/snglinst.h> wxSingleInstanceChecker* LockFile( const wxString& aFileName ) { // first make absolute and normalize, to avoid that different lock files // for the same file can be created wxFileName fn( aFileName ); fn.MakeAbsolute(); wxString lockFileName = fn.GetFullPath() + wxT( ".lock" ); lockFileName.Replace( wxT( "/" ), wxT( "_" ) ); // We can have filenames coming from Windows, so also convert Windows separator lockFileName.Replace( wxT( "\\" ), wxT( "_" ) ); wxSingleInstanceChecker* p = new wxSingleInstanceChecker( lockFileName ); if( p->IsAnotherRunning() ) { delete p; p = NULL; } return p; }
common/pgm_base.cpp +0 −44 Original line number Diff line number Diff line Loading @@ -262,7 +262,6 @@ static LANGUAGE_DESCR s_Languages[] = PGM_BASE::PGM_BASE() { m_pgm_checker = NULL; m_file_checker = NULL; m_locale = NULL; m_common_settings = NULL; Loading Loading @@ -290,20 +289,10 @@ void PGM_BASE::destroy() delete m_pgm_checker; m_pgm_checker = 0; delete m_file_checker; m_file_checker = 0; delete m_locale; m_locale = 0; } void PGM_BASE::ReleaseFile() { // Release the current file marked in use. delete m_file_checker; m_file_checker = 0; } void PGM_BASE::SetEditorName( const wxString& aFileName ) { Loading Loading @@ -677,36 +666,3 @@ void PGM_BASE::AddMenuLanguageList( wxMenu* MasterMenu ) } } bool PGM_BASE::LockFile( const wxString& aFileName ) { // first make absolute and normalize, to avoid that different lock files // for the same file can be created wxFileName fn( aFileName ); fn.MakeAbsolute(); // semaphore to protect the edition of the file by more than one instance if( m_file_checker != NULL ) { // it means that we had an open file and we are opening a different one delete m_file_checker; } wxString lockFileName = fn.GetFullPath() + wxT( ".lock" ); lockFileName.Replace( wxT( "/" ), wxT( "_" ) ); // We can have filenames coming from Windows, so also convert Windows separator lockFileName.Replace( wxT( "\\" ), wxT( "_" ) ); m_file_checker = new wxSingleInstanceChecker( lockFileName ); if( m_file_checker && m_file_checker->IsAnotherRunning() ) { return false; } return true; }
eeschema/files-io.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -191,7 +191,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "bug in single_top.cpp or project manager." ) ); if( !Pgm().LockFile( fullFileName ) ) if( !LockFile( fullFileName ) ) { wxString msg = wxString::Format( _( "Schematic file '%s' is already open." ), Loading