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
322aae6a
Commit
322aae6a
authored
Nov 02, 2014
by
Dick Hollenbeck
Committed by
Wayne Stambaugh
Nov 02, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for existence of *.sch file so Eeschema does not create a new one.
parent
40f044bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
sheet.cpp
eeschema/sheet.cpp
+27
-19
No files found.
eeschema/sheet.cpp
View file @
322aae6a
...
...
@@ -36,6 +36,7 @@
#include <dialogs/dialog_sch_sheet_props.h>
#include <wildcards_and_files_ext.h>
#include <project.h>
bool
SCH_EDIT_FRAME
::
EditSheet
(
SCH_SHEET
*
aSheet
,
wxDC
*
aDC
)
...
...
@@ -85,7 +86,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
// Duplicate sheet names are not valid.
const
SCH_SHEET
*
sheet
=
GetScreen
()
->
GetSheet
(
dlg
.
GetSheetName
()
);
if
(
(
sheet
!=
NULL
)
&&
(
sheet
!=
aSheet
)
)
if
(
sheet
&&
sheet
!=
aSheet
)
{
DisplayError
(
this
,
wxString
::
Format
(
_
(
"A sheet named
\"
%s
\"
already exists."
),
GetChars
(
dlg
.
GetSheetName
()
)
)
);
...
...
@@ -101,29 +102,36 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
bool
loadFromFile
=
false
;
SCH_SCREEN
*
useScreen
=
NULL
;
wxString
newFullFilename
=
fileName
.
GetFullPath
();
// Inside Eeschema, filenames are stored using unix notation
newFullFilename
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
wxString
newFilename
=
fileName
.
GetFullPath
();
// Search for a schematic file having the same filename
// already in use in the hierarchy or on disk, in order to reuse it.
if
(
!
g_RootSheet
->
SearchHierarchy
(
newFilename
,
&
useScreen
)
)
{
// if user entered a relative path, allow that to stay, but do the
// file existence test with an absolute (full) path. This transformation
// is local to this scope, but is the same one used at load time later.
wxString
absolute
=
Prj
().
AbsolutePath
(
newFilename
);
// Search for a schematic file having the same filename exists,
// already in use in the hierarchy, or on disk,
// in order to reuse it
if
(
!
g_RootSheet
->
SearchHierarchy
(
newFullFilename
,
&
useScreen
)
)
loadFromFile
=
fileName
.
FileExists
(
);
loadFromFile
=
wxFileExists
(
absolute
);
}
// Inside Eeschema, filenames are stored using unix notation
newFilename
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
if
(
aSheet
->
GetScreen
()
==
NULL
)
// New sheet.
{
if
(
(
useScreen
!=
NULL
)
||
loadFromFile
)
// Load from existing file.
if
(
useScreen
||
loadFromFile
)
// Load from existing file.
{
if
(
useScreen
!=
NULL
)
{
msg
.
Printf
(
_
(
"A file named '%s' already exists in the current schematic hierarchy."
),
GetChars
(
newF
ullF
ilename
)
);
GetChars
(
newFilename
)
);
}
else
{
msg
.
Printf
(
_
(
"A file named '%s' already exists."
),
GetChars
(
newF
ullF
ilename
)
);
GetChars
(
newFilename
)
);
}
msg
+=
_
(
"
\n\n
Do you want to create a sheet with the contents of this file?"
);
...
...
@@ -139,7 +147,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
else
// New file.
{
aSheet
->
SetScreen
(
new
SCH_SCREEN
(
&
Kiway
()
)
);
aSheet
->
GetScreen
()
->
SetFileName
(
newF
ullF
ilename
);
aSheet
->
GetScreen
()
->
SetFileName
(
newFilename
);
}
}
else
// Existing sheet.
...
...
@@ -151,24 +159,24 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
// to avoid issues under Windows, although under Unix
// filenames are case sensitive.
// But many users create schematic under both Unix and Windows
if
(
newF
ullF
ilename
.
CmpNoCase
(
aSheet
->
GetFileName
()
)
!=
0
)
if
(
newFilename
.
CmpNoCase
(
aSheet
->
GetFileName
()
)
!=
0
)
{
// Sheet file name changes cannot be undone.
isUndoable
=
false
;
msg
=
_
(
"Changing the sheet file name cannot be undone. "
);
if
(
(
useScreen
!=
NULL
)
||
loadFromFile
)
// Load from existing file.
if
(
useScreen
||
loadFromFile
)
// Load from existing file.
{
wxString
tmp
;
if
(
useScreen
!=
NULL
)
{
tmp
.
Printf
(
_
(
"A file named <%s> already exists in the current schematic hierarchy."
),
GetChars
(
newF
ullF
ilename
)
);
GetChars
(
newFilename
)
);
}
else
{
tmp
.
Printf
(
_
(
"A file named <%s> already exists."
),
GetChars
(
newF
ullF
ilename
)
);
GetChars
(
newFilename
)
);
}
msg
+=
tmp
;
...
...
@@ -203,7 +211,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if
(
renameFile
)
{
aSheet
->
GetScreen
()
->
SetFileName
(
newF
ullF
ilename
);
aSheet
->
GetScreen
()
->
SetFileName
(
newFilename
);
SaveEEFile
(
aSheet
->
GetScreen
()
);
// If the the associated screen is shared by more than one sheet, remove the
...
...
@@ -217,7 +225,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
}
}
aSheet
->
SetFileName
(
newF
ullF
ilename
);
aSheet
->
SetFileName
(
newFilename
);
if
(
useScreen
)
aSheet
->
SetScreen
(
useScreen
);
...
...
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