@@ -3807,6 +3807,9 @@ void Document::_removeObject(DocumentObject* pcObject)
38073807 _checkTransaction (pcObject, nullptr , __LINE__);
38083808
38093809 auto pos = d->objectMap .find (pcObject->getNameInDocument ());
3810+ if (pos == d->objectMap .end ()) {
3811+ FC_ERR (" Internal error, could not find " << pcObject->getFullName () << " to remove" );
3812+ }
38103813
38113814 if (!d->rollback && d->activeUndoTransaction && pos->second ->hasChildElement ()) {
38123815 // Preserve link group children global visibility. See comments in
@@ -4272,15 +4275,15 @@ std::vector<App::DocumentObject*> Document::getRootObjectsIgnoreLinks() const
42724275{
42734276 std::vector<App::DocumentObject*> ret;
42744277
4275- for (auto objectIt : d->objectArray ) {
4278+ for (const auto & objectIt : d->objectArray ) {
42764279 auto list = objectIt->getInList ();
42774280 bool noParents = list.empty ();
42784281
42794282 if (!noParents) {
42804283 // App::Document getRootObjects returns the root objects of the dependency graph.
4281- // So if an object is referenced by a App::Link, it will not be returned by that
4284+ // So if an object is referenced by an App::Link, it will not be returned by that
42824285 // function. So here, as we want the tree-root level objects, we check if all the
4283- // parents are links. In which case its still a root object.
4286+ // parents are links. In which case it's still a root object.
42844287 noParents = std::all_of (list.cbegin (), list.cend (), [](App::DocumentObject* obj) {
42854288 return obj->isDerivedFrom <App::Link>();
42864289 });
@@ -4300,21 +4303,19 @@ void DocumentP::findAllPathsAt(const std::vector<Node>& all_nodes,
43004303 Path tmp)
43014304{
43024305 if (std::find (tmp.begin (), tmp.end (), id) != tmp.end ()) {
4303- Path tmp2 (tmp);
4304- tmp2.push_back (id);
4305- all_paths.push_back (tmp2);
4306+ tmp.push_back (id);
4307+ all_paths.push_back (std::move (tmp));
43064308 return ; // a cycle
43074309 }
43084310
43094311 tmp.push_back (id);
43104312 if (all_nodes[id].empty ()) {
4311- all_paths.push_back (tmp);
4313+ all_paths.push_back (std::move ( tmp) );
43124314 return ;
43134315 }
43144316
43154317 for (size_t i = 0 ; i < all_nodes[id].size (); i++) {
4316- Path tmp2 (tmp);
4317- findAllPathsAt (all_nodes, all_nodes[id][i], all_paths, tmp2);
4318+ findAllPathsAt (all_nodes, all_nodes[id][i], all_paths, tmp);
43184319 }
43194320}
43204321
@@ -4344,18 +4345,18 @@ Document::getPathsByOutList(const App::DocumentObject* from, const App::Document
43444345 size_t index_to = indexMap[to];
43454346 Path tmp;
43464347 std::vector<Path> all_paths;
4347- DocumentP::findAllPathsAt (all_nodes, index_from, all_paths, tmp);
4348+ DocumentP::findAllPathsAt (all_nodes, index_from, all_paths, std::move ( tmp) );
43484349
43494350 for (const Path& it : all_paths) {
43504351 Path::const_iterator jt = std::find (it.begin (), it.end (), index_to);
43514352 if (jt != it.end ()) {
4352- std::list<App::DocumentObject*> path;
4353+ array.push_back ({});
4354+ auto & path = array.back ();
43534355 for (Path::const_iterator kt = it.begin (); kt != jt; ++kt) {
43544356 path.push_back (d->objectArray [*kt]);
43554357 }
43564358
43574359 path.push_back (d->objectArray [*jt]);
4358- array.push_back (path);
43594360 }
43604361 }
43614362
0 commit comments