Fixed issue #1242 (KLayout 0.28.2 crashes when registering a plugin if a layout exists)

Problem was twofold: first, events are triggered during
construction of the plugin which met an uninitialized
pointer. Second, the clearing of existing plugins failed
because of iterating a vector while destroying it's members
erased member of it.
This commit is contained in:
Matthias Koefferlein
2023-01-04 21:17:12 +01:00
parent a85dbd3d31
commit ef6f3f182a
3 changed files with 48 additions and 6 deletions
+3 -2
View File
@@ -578,10 +578,11 @@ void LayoutViewBase::drop_url (const std::string &path_or_url)
void LayoutViewBase::clear_plugins ()
{
for (std::vector<lay::Plugin *>::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) {
std::vector<lay::Plugin *> plugins;
mp_plugins.swap (plugins);
for (std::vector<lay::Plugin *>::iterator p = plugins.begin (); p != plugins.end (); ++p) {
delete *p;
}
mp_plugins.clear ();
mp_active_plugin = 0;
}