mirror of
https://github.com/autc04/Retro68.git
synced 2024-06-17 21:30:02 +00:00
ConvertObj: fix segaults in module sorting
This commit is contained in:
parent
3327705fb3
commit
9e0f85dbde
|
@ -213,19 +213,25 @@ void sortModules(std::vector<std::shared_ptr<Module>>& modules)
|
||||||
continue;
|
continue;
|
||||||
if(r.second.name2.empty())
|
if(r.second.name2.empty())
|
||||||
{
|
{
|
||||||
std::shared_ptr<Module> m1;
|
if(auto p = nameMap.find(r.second.name1); p != nameMap.end())
|
||||||
m1 = nameMap.find(r.second.name1)->second;
|
{
|
||||||
m1->nearrefs.push_back(m);
|
std::shared_ptr<Module> m1 = p->second;
|
||||||
m->nearrefs.push_back(m1);
|
m1->nearrefs.push_back(m);
|
||||||
|
m->nearrefs.push_back(m1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::shared_ptr<Module> m1;
|
auto p1 = nameMap.find(r.second.name1);
|
||||||
m1 = nameMap.find(r.second.name1)->second;
|
auto p2 = nameMap.find(r.second.name2);
|
||||||
std::shared_ptr<Module> m2;
|
|
||||||
m2 = nameMap.find(r.second.name2)->second;
|
if(p1 != nameMap.end() && p2 != nameMap.end())
|
||||||
m1->nearrefs.push_back(m2);
|
{
|
||||||
m2->nearrefs.push_back(m1);
|
std::shared_ptr<Module> m1 = p1->second;
|
||||||
|
std::shared_ptr<Module> m2 = p2->second;
|
||||||
|
m1->nearrefs.push_back(m2);
|
||||||
|
m2->nearrefs.push_back(m1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,8 +259,11 @@ void sortModules(std::vector<std::shared_ptr<Module>>& modules)
|
||||||
}
|
}
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
sorted.push_back(nameMap[*unemitted.begin()]);
|
if(!unemitted.empty())
|
||||||
unemitted.erase(unemitted.begin());
|
{
|
||||||
|
sorted.push_back(nameMap[*unemitted.begin()]);
|
||||||
|
unemitted.erase(unemitted.begin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sorted.swap(modules);
|
sorted.swap(modules);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user