From 38705457c8ad98c5d199f61856bf0a51a0d61654 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Wed, 7 Aug 2013 21:13:09 +0100 Subject: [PATCH] Issue #39. Reduced number of overlaps recorded that would get ignored later. I'd also assumed that all plugins listed would exist, forgetting that BOSS just adds error messages and doesn't fail at that stage, so added checks for that. Also figured out why adding edges to the graph was crashing: it doesn't seem to like connecting to the last vertex in the graph. Haven't figured out where I'm going wrong beyond that though. --- src/backend/graph.cpp | 2 ++ src/gui/main.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/backend/graph.cpp b/src/backend/graph.cpp index 75129310..ce620f79 100644 --- a/src/backend/graph.cpp +++ b/src/backend/graph.cpp @@ -61,6 +61,8 @@ namespace boss { std::string key; list::const_iterator value; //Priority values should override the number of override records as the deciding factor if they differ. + if (it->MustLoadAfter(*jt) || jt->MustLoadAfter(*it)) + break; if (it->Priority() < jt->Priority()) { key = jt->Name(); value = it; diff --git a/src/gui/main.cpp b/src/gui/main.cpp index a3ae0460..99d4f19f 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -598,8 +598,12 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { BOOST_LOG_TRIVIAL(trace) << "Adding out-edges for non-master plugins."; //Need to add out-edges to all non-master plugins. for (list::const_iterator jt=firstNonMaster, endIt; jt != endIt; ++jt) { + size_t pos = std::distance(beginIt, jt); + BOOST_LOG_TRIVIAL(trace) << "Current position: " << pos << ", list size: " << plugins.size() << ", number of vertices: " << boost::num_vertices(graph); + if (pos == plugins.size() - 1) + break; BOOST_LOG_TRIVIAL(trace) << "Getting vertex for \"" << jt->Name() << "\"."; - boss::vertex_t childVertex = boost::vertex( std::distance(beginIt, jt), graph ); + boss::vertex_t childVertex = boost::vertex(pos , graph ); //Now that we have the non-master plugin's vertex, create an edge between the two. BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << it->Name() << "\" to \"" << jt->Name() << "\"."; @@ -612,6 +616,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { for (vector::const_iterator jt=strVec.begin(), endjt=strVec.end(); jt != endjt; ++jt) { //Find the other plugin. result = std::find(plugins.begin(), plugins.end(), boss::Plugin(*jt)); + if (result == plugins.end()) + continue; //Add the vertex (again assuming that duplicates won't be created). boss::vertex_t parentVertex = boost::vertex( std::distance(beginIt, result), graph); boost::add_edge(parentVertex, vertex, graph); @@ -624,6 +630,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { if (boss::IsPlugin(jt->Name())) { //Find the other plugin. result = std::find(plugins.begin(), plugins.end(), *jt); + if (result == plugins.end()) + continue; //Add the vertex (again assuming that duplicates won't be created). boss::vertex_t parentVertex = boost::vertex( std::distance(beginIt, result), graph); boost::add_edge(parentVertex, vertex, graph); @@ -637,6 +645,8 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { if (boss::IsPlugin(jt->Name())) { //Find the other plugin. result = std::find(plugins.begin(), plugins.end(), *jt); + if (result == plugins.end()) + continue; //Add the vertex (again assuming that duplicates won't be created). boss::vertex_t parentVertex = boost::vertex( std::distance(beginIt, result), graph); boost::add_edge(parentVertex, vertex, graph); @@ -648,8 +658,10 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) { boost::unordered_map< std::string, std::vector::const_iterator> >::const_iterator overlapIt = overlapMap.find(it->Name()); if (overlapIt != overlapMap.end()) { for (vector::const_iterator>::const_iterator jt=overlapIt->second.begin(), endjt=overlapIt->second.end(); jt != endjt; ++jt) { + BOOST_LOG_TRIVIAL(trace) << "Getting vertex for \"" << (*jt)->Name() << "\"."; boss::vertex_t parentVertex = boost::vertex( std::distance(beginIt, *jt), graph); + BOOST_LOG_TRIVIAL(trace) << "Checking if there is already a vertex between the plugins in the opposite direction."; if (!boost::edge(vertex, parentVertex, graph).second) { //No edge going the other way, OK to add this edge. boost::add_edge(parentVertex, vertex, graph);