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
e8bb7d1e
Commit
e8bb7d1e
authored
Oct 12, 2010
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix segfault when replacing an existing component in a library.
parent
b1ffd179
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
class_library.cpp
eeschema/class_library.cpp
+11
-5
No files found.
eeschema/class_library.cpp
View file @
e8bb7d1e
...
...
@@ -344,18 +344,24 @@ LIB_COMPONENT* CMP_LIBRARY::ReplaceComponent( LIB_COMPONENT* aOldComponent,
wxASSERT
(
aNewComponent
!=
NULL
);
wxASSERT
(
aOldComponent
->
GetName
().
CmpNoCase
(
aNewComponent
->
GetName
()
)
==
0
);
/* Remove the old root component. The component will automatically be removed when all
* it's aliases are deleted.
/* Remove the old root component. The component will automatically be deleted
* when all it's aliases are deleted. Do not place any code that accesses
* aOldComponent inside this loop that gets evaluated after the last alias is
* removed in RemoveEntry(). Failure to heed this warning will result in a
* segfault.
*/
BOOST_FOREACH
(
LIB_ALIAS
*
alias
,
aOldComponent
->
m_aliases
)
size_t
i
=
aOldComponent
->
m_aliases
.
size
();
while
(
i
!=
0
)
{
RemoveEntry
(
(
CMP_LIB_ENTRY
*
)
alias
);
i
-=
1
;
RemoveEntry
(
(
CMP_LIB_ENTRY
*
)
aOldComponent
->
m_aliases
[
i
]
);
}
LIB_COMPONENT
*
newCmp
=
new
LIB_COMPONENT
(
*
aNewComponent
,
this
);
// Add new aliases to library alias map.
for
(
size_t
i
=
0
;
i
<
newCmp
->
m_aliases
.
size
();
i
++
)
for
(
i
=
0
;
i
<
newCmp
->
m_aliases
.
size
();
i
++
)
{
aliases
[
newCmp
->
m_aliases
[
i
]
->
GetName
()
]
=
newCmp
->
m_aliases
[
i
];
}
...
...
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