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
9a6612c6
Commit
9a6612c6
authored
Apr 18, 2012
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use a block scope to invoke wxFFile's destructor before renaming temporary file
parent
f3e17179
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
legacy_plugin.cpp
pcbnew/legacy_plugin.cpp
+20
-13
No files found.
pcbnew/legacy_plugin.cpp
View file @
9a6612c6
...
...
@@ -3933,23 +3933,30 @@ void FPL_CACHE::Save()
wxString
tempFileName
=
wxFileName
::
CreateTempFileName
(
m_lib_name
);
wxLogDebug
(
"tempFileName:'%s'
\n
"
,
TO_UTF8
(
tempFileName
)
);
//
wxLogDebug( "tempFileName:'%s'\n", TO_UTF8( tempFileName ) );
FILE
*
fp
=
wxFopen
(
tempFileName
,
wxT
(
"w"
)
);
if
(
!
fp
)
// a block {} scope to fire wxFFile wxf()'s destructor
{
THROW_IO_ERROR
(
wxString
::
Format
(
_
(
"Unable to open or create legacy library file '%s'"
),
m_lib_name
.
GetData
()
)
);
}
FILE
*
fp
=
wxFopen
(
tempFileName
,
wxT
(
"w"
)
);
if
(
!
fp
)
{
THROW_IO_ERROR
(
wxString
::
Format
(
_
(
"Unable to open or create legacy library file '%s'"
),
m_lib_name
.
GetData
()
)
);
}
// wxf now owns fp, will close on exception or return
wxFFile
wxf
(
fp
);
// wxf now owns fp, will close on exception or exit from
// this block {} scope
wxFFile
wxf
(
fp
);
SaveHeader
(
fp
);
SaveIndex
(
fp
);
SaveModules
(
fp
);
SaveEndOfFile
(
fp
);
}
SaveHeader
(
fp
);
SaveIndex
(
fp
);
SaveModules
(
fp
);
SaveEndOfFile
(
fp
);
// fp is now closed here, and that seems proper before trying to rename
// the temporary file to m_lib_name.
wxRemove
(
m_lib_name
);
// it is not an error if this does not exist
...
...
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