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
Show 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 @@
...
@@ -36,6 +36,7 @@
#include <dialogs/dialog_sch_sheet_props.h>
#include <dialogs/dialog_sch_sheet_props.h>
#include <wildcards_and_files_ext.h>
#include <wildcards_and_files_ext.h>
#include <project.h>
bool
SCH_EDIT_FRAME
::
EditSheet
(
SCH_SHEET
*
aSheet
,
wxDC
*
aDC
)
bool
SCH_EDIT_FRAME
::
EditSheet
(
SCH_SHEET
*
aSheet
,
wxDC
*
aDC
)
...
@@ -85,7 +86,7 @@ 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.
// Duplicate sheet names are not valid.
const
SCH_SHEET
*
sheet
=
GetScreen
()
->
GetSheet
(
dlg
.
GetSheetName
()
);
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."
),
DisplayError
(
this
,
wxString
::
Format
(
_
(
"A sheet named
\"
%s
\"
already exists."
),
GetChars
(
dlg
.
GetSheetName
()
)
)
);
GetChars
(
dlg
.
GetSheetName
()
)
)
);
...
@@ -101,29 +102,36 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
...
@@ -101,29 +102,36 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
bool
loadFromFile
=
false
;
bool
loadFromFile
=
false
;
SCH_SCREEN
*
useScreen
=
NULL
;
SCH_SCREEN
*
useScreen
=
NULL
;
wxString
newFullFilename
=
fileName
.
GetFullPath
();
wxString
newFilename
=
fileName
.
GetFullPath
();
// Inside Eeschema, filenames are stored using unix notation
newFullFilename
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
// 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,
loadFromFile
=
wxFileExists
(
absolute
);
// already in use in the hierarchy, or on disk,
}
// in order to reuse it
if
(
!
g_RootSheet
->
SearchHierarchy
(
newFullFilename
,
&
useScreen
)
)
// Inside Eeschema, filenames are stored using unix notation
loadFromFile
=
fileName
.
FileExists
(
);
newFilename
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
if
(
aSheet
->
GetScreen
()
==
NULL
)
// New sheet.
if
(
aSheet
->
GetScreen
()
==
NULL
)
// New sheet.
{
{
if
(
(
useScreen
!=
NULL
)
||
loadFromFile
)
// Load from existing file.
if
(
useScreen
||
loadFromFile
)
// Load from existing file.
{
{
if
(
useScreen
!=
NULL
)
if
(
useScreen
!=
NULL
)
{
{
msg
.
Printf
(
_
(
"A file named '%s' already exists in the current schematic hierarchy."
),
msg
.
Printf
(
_
(
"A file named '%s' already exists in the current schematic hierarchy."
),
GetChars
(
newF
ullF
ilename
)
);
GetChars
(
newFilename
)
);
}
}
else
else
{
{
msg
.
Printf
(
_
(
"A file named '%s' already exists."
),
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?"
);
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 )
...
@@ -139,7 +147,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
else
// New file.
else
// New file.
{
{
aSheet
->
SetScreen
(
new
SCH_SCREEN
(
&
Kiway
()
)
);
aSheet
->
SetScreen
(
new
SCH_SCREEN
(
&
Kiway
()
)
);
aSheet
->
GetScreen
()
->
SetFileName
(
newF
ullF
ilename
);
aSheet
->
GetScreen
()
->
SetFileName
(
newFilename
);
}
}
}
}
else
// Existing sheet.
else
// Existing sheet.
...
@@ -151,24 +159,24 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
...
@@ -151,24 +159,24 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
// to avoid issues under Windows, although under Unix
// to avoid issues under Windows, although under Unix
// filenames are case sensitive.
// filenames are case sensitive.
// But many users create schematic under both Unix and Windows
// 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.
// Sheet file name changes cannot be undone.
isUndoable
=
false
;
isUndoable
=
false
;
msg
=
_
(
"Changing the sheet file name cannot be undone. "
);
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
;
wxString
tmp
;
if
(
useScreen
!=
NULL
)
if
(
useScreen
!=
NULL
)
{
{
tmp
.
Printf
(
_
(
"A file named <%s> already exists in the current schematic hierarchy."
),
tmp
.
Printf
(
_
(
"A file named <%s> already exists in the current schematic hierarchy."
),
GetChars
(
newF
ullF
ilename
)
);
GetChars
(
newFilename
)
);
}
}
else
else
{
{
tmp
.
Printf
(
_
(
"A file named <%s> already exists."
),
tmp
.
Printf
(
_
(
"A file named <%s> already exists."
),
GetChars
(
newF
ullF
ilename
)
);
GetChars
(
newFilename
)
);
}
}
msg
+=
tmp
;
msg
+=
tmp
;
...
@@ -203,7 +211,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
...
@@ -203,7 +211,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if
(
renameFile
)
if
(
renameFile
)
{
{
aSheet
->
GetScreen
()
->
SetFileName
(
newF
ullF
ilename
);
aSheet
->
GetScreen
()
->
SetFileName
(
newFilename
);
SaveEEFile
(
aSheet
->
GetScreen
()
);
SaveEEFile
(
aSheet
->
GetScreen
()
);
// If the the associated screen is shared by more than one sheet, remove the
// 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 )
...
@@ -217,7 +225,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
}
}
}
}
aSheet
->
SetFileName
(
newF
ullF
ilename
);
aSheet
->
SetFileName
(
newFilename
);
if
(
useScreen
)
if
(
useScreen
)
aSheet
->
SetScreen
(
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