diff --git a/src/backend/graph.cpp b/src/backend/graph.cpp index 1ab77325..c7050494 100644 --- a/src/backend/graph.cpp +++ b/src/backend/graph.cpp @@ -42,12 +42,27 @@ namespace loot { cycle_detector::cycle_detector() {} + void cycle_detector::tree_edge(edge_t e, const PluginGraph& g) { + vertex_t source = boost::source(e, g); + + trail.push_back(g[source].Name()); + } + void cycle_detector::back_edge(edge_t e, const PluginGraph& g) { vertex_t vSource = boost::source(e, g); vertex_t vTarget = boost::target(e, g); - BOOST_LOG_TRIVIAL(error) << "Cyclic interaction detected between plugins \"" << g[vSource].Name() << "\" and \"" << g[vTarget].Name() << "\"."; - throw loot::error(loot::error::sorting_error, (boost::format(lc::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\".")) % g[vSource].Name() % g[vTarget].Name()).str()); + trail.push_back(g[vSource].Name()); + list::iterator it = find(trail.begin(), trail.end(), g[vTarget].Name()); + string backCycle; + for (list::iterator endIt = trail.end(); it != endIt; ++it) { + backCycle += *it + ", "; + } + backCycle.erase(backCycle.length() - 2); + + BOOST_LOG_TRIVIAL(error) << "Cyclic interaction detected between plugins \"" << g[vSource].Name() << "\" and \"" << g[vTarget].Name() << "\". Back cycle: " << backCycle; + + throw loot::error(loot::error::sorting_error, (boost::format(lc::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\". Back cycle: %3%")) % g[vSource].Name() % g[vTarget].Name() % backCycle).str()); } bool GetVertexByName(const PluginGraph& graph, const std::string& name, vertex_t& vertex) { diff --git a/src/backend/graph.h b/src/backend/graph.h index f0b696fa..faad4781 100644 --- a/src/backend/graph.h +++ b/src/backend/graph.h @@ -45,6 +45,9 @@ namespace loot { struct cycle_detector : public boost::dfs_visitor<> { cycle_detector(); + std::list trail; + + void tree_edge(edge_t e, const PluginGraph& g); void back_edge(edge_t e, const PluginGraph& g); };