Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
3e861db3
Commit
3e861db3
authored
Sep 07, 2014
by
Dick Hollenbeck
Committed by
Wayne Stambaugh
Sep 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lock file improvements.
parent
da4055ae
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
91 additions
and
71 deletions
+91
-71
CMakeLists.txt
common/CMakeLists.txt
+1
-0
draw_frame.cpp
common/draw_frame.cpp
+22
-0
lockfile.cpp
common/lockfile.cpp
+32
-0
pgm_base.cpp
common/pgm_base.cpp
+0
-44
files-io.cpp
eeschema/files-io.cpp
+1
-1
schframe.cpp
eeschema/schframe.cpp
+1
-2
common.h
include/common.h
+8
-0
draw_frame.h
include/draw_frame.h
+22
-3
pgm_base.h
include/pgm_base.h
+0
-17
wxEeschemaStruct.h
include/wxEeschemaStruct.h
+1
-0
dialog_pad_properties.cpp
pcbnew/dialogs/dialog_pad_properties.cpp
+2
-1
files.cpp
pcbnew/files.cpp
+1
-1
pcbframe.cpp
pcbnew/pcbframe.cpp
+0
-2
No files found.
common/CMakeLists.txt
View file @
3e861db3
...
...
@@ -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
...
...
common/draw_frame.cpp
View file @
3e861db3
...
...
@@ -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>
...
...
@@ -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
;
...
...
@@ -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
);
}
...
...
common/lockfile.cpp
0 → 100644
View file @
3e861db3
#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
View file @
3e861db3
...
...
@@ -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
;
...
...
@@ -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
)
{
...
...
@@ -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
View file @
3e861db3
...
...
@@ -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."
),
...
...
eeschema/schframe.cpp
View file @
3e861db3
...
...
@@ -417,10 +417,9 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
m_undoItem
=
NULL
;
g_RootSheet
=
NULL
;
m_findReplaceData
=
NULL
;
Pgm
().
ReleaseFile
();
// Release the lock on root file
}
void
SCH_EDIT_FRAME
::
SetRepeatItem
(
SCH_ITEM
*
aItem
)
{
// we cannot store a pointer to an item in the display list here since
...
...
include/common.h
View file @
3e861db3
...
...
@@ -45,6 +45,7 @@
class
wxAboutDialogInfo
;
class
SEARCH_STACK
;
class
wxSingleInstanceChecker
;
// Flag for special keys
...
...
@@ -608,6 +609,13 @@ void SystemDirsAppend( SEARCH_STACK* aSearchStack );
*/
wxString
SearchHelpFileFullPath
(
const
SEARCH_STACK
&
aSearchStack
,
const
wxString
&
aBaseName
);
/**
* Function LockFile
* tests to see if aFileName can be locked (is not already locked) and only then
* returns a wxSingleInstanceChecker protecting aFileName. Caller owns the return value.
*/
wxSingleInstanceChecker
*
LockFile
(
const
wxString
&
aFileName
);
/// Put aPriorityPath in front of all paths in the value of aEnvVar.
const
wxString
PrePendPath
(
const
wxString
&
aEnvVar
,
const
wxString
&
aPriorityPath
);
...
...
include/draw_frame.h
View file @
3e861db3
...
...
@@ -28,6 +28,8 @@
#include <wxstruct.h>
#include <kiway_player.h>
class
wxSingleInstanceChecker
;
/**
* Class EDA_DRAW_FRAME
...
...
@@ -43,14 +45,17 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER
///< Id of active button on the vertical toolbar.
int
m_toolId
;
BASE_SCREEN
*
m_currentScreen
;
///< current used SCREEN
BASE_SCREEN
*
m_currentScreen
;
///< current used SCREEN
bool
m_snapToGrid
;
///< Indicates if cursor should be snapped to grid.
bool
m_galCanvasActive
;
///< whether to use new GAL engine
bool
m_snapToGrid
;
///< Indicates if cursor should be snapped to grid.
bool
m_galCanvasActive
;
///< whether to use new GAL engine
EDA_DRAW_PANEL_GAL
*
m_galCanvas
;
protected
:
wxSingleInstanceChecker
*
m_file_checker
;
///< prevents opening same file multiple times.
EDA_HOTKEY_CONFIG
*
m_HotkeysZoomAndGridList
;
int
m_LastGridSizeId
;
// the command id offset (>= 0) of the last selected grid
// 0 is for the grid corresponding to
...
...
@@ -143,6 +148,20 @@ public:
~
EDA_DRAW_FRAME
();
/**
* Function LockFile
* marks a schematic file as being in use. Use ReleaseFile() to undo this.
* @param aFileName = full path to the file.
* @return false if the file was already locked, true otherwise.
*/
bool
LockFile
(
const
wxString
&
aFileName
);
/**
* Function ReleaseFile
* Release the current file marked in use. See m_file_checker.
*/
void
ReleaseFile
();
virtual
void
SetPageSettings
(
const
PAGE_INFO
&
aPageSettings
)
=
0
;
virtual
const
PAGE_INFO
&
GetPageSettings
()
const
=
0
;
...
...
include/pgm_base.h
View file @
3e861db3
...
...
@@ -168,20 +168,6 @@ public:
*/
VTBL_ENTRY
void
WritePdfBrowserInfos
();
/**
* Function LockFile
* marks a file as being in use.
* @param aFileName = full path to the file.
* @return false if the file was already locked, true otherwise.
*/
VTBL_ENTRY
bool
LockFile
(
const
wxString
&
aFileName
);
/**
* Function ReleaseFile
* Release the current file marked in use.
*/
VTBL_ENTRY
void
ReleaseFile
();
/**
* Function App
* returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP, or kicad.exe.
...
...
@@ -227,9 +213,6 @@ protected:
/// prevents multiple instances of a program from being run at the same time.
wxSingleInstanceChecker
*
m_pgm_checker
;
/// prevents opening the same file multiple times.
wxSingleInstanceChecker
*
m_file_checker
;
/// Configuration settings common to all KiCad program modules,
/// like as in $HOME/.kicad_common
wxConfigBase
*
m_common_settings
;
...
...
include/wxEeschemaStruct.h
View file @
3e861db3
...
...
@@ -117,6 +117,7 @@ class SCH_EDIT_FRAME : public SCH_BASE_FRAME
private
:
SCH_SHEET_PATH
*
m_CurrentSheet
;
///< which sheet we are presently working on.
wxString
m_DefaultSchematicFileName
;
PARAM_CFG_ARRAY
m_projectFileParams
;
PARAM_CFG_ARRAY
m_configSettings
;
wxPageSetupDialogData
m_pageSetupData
;
...
...
pcbnew/dialogs/dialog_pad_properties.cpp
View file @
3e861db3
...
...
@@ -770,11 +770,12 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
error_msgs
.
Add
(
_
(
"Error: Connector pads are not on the solder paste layer
\n
"
"Use SMD pads instead"
)
);
// Fall trough
/*
case PAD_SMD: // SMD and Connector pads (One external copper layer only)
if( padlayers_mask[B_Cu] && padlayers_mask[F_Cu] )
error_msgs.Add( _( "Error: only one copper layer allowed for SMD or Connector pads" ) );
break;
*/
}
if
(
error_msgs
.
GetCount
()
)
...
...
pcbnew/files.cpp
View file @
3e861db3
...
...
@@ -395,7 +395,7 @@ bool PCB_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
(
_
(
"PCB file '%s' is already open."
),
...
...
pcbnew/pcbframe.cpp
View file @
3e861db3
...
...
@@ -486,8 +486,6 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
m_Macros
[
i
].
m_Record
.
clear
();
delete
m_drc
;
Pgm
().
ReleaseFile
();
// Release the lock on PCB file
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment