Revision: 78158
http://sourceforge.net/p/brlcad/code/78158
Author: starseeker
Date: 2021-02-01 15:25:58 +0000 (Mon, 01 Feb 2021)
Log Message:
-----------
Add a final check to spot missing objects added to pushed trees.
Modified Paths:
--------------
brlcad/trunk/src/libged/npush/npush.cpp
Modified: brlcad/trunk/src/libged/npush/npush.cpp
===================================================================
--- brlcad/trunk/src/libged/npush/npush.cpp 2021-02-01 14:15:31 UTC (rev
78157)
+++ brlcad/trunk/src/libged/npush/npush.cpp 2021-02-01 15:25:58 UTC (rev
78158)
@@ -156,12 +156,14 @@
/* Container to hold information during tree walk. */
struct push_state {
- /* Variables used for initial validity checking of specified push
- * object(s). The target_objects set is user specified - if objects are
- * specified that are below other target objects, flag valid_push is set to
- * false and the user gets an error report. */
+ /* Variables used for validity checking of specified push object(s). The
+ * target_objects set is user specified - if objects are specified that are
+ * below other target objects, flag valid_push is set to false and the user
+ * gets an error report. */
bool valid_push = true;
std::set<std::string> target_objs;
+ std::set<std::string> initial_missing;
+ bool final_check = false;
/* User-supplied flags controlling tree walking behavior */
int max_depth = 0;
@@ -258,13 +260,27 @@
case OP_DB_LEAF:
- if ((dp=db_lookup(dbip, tp->tr_l.tl_name, LOOKUP_NOISY)) ==
RT_DIR_NULL)
+ if ((dp=db_lookup(dbip, tp->tr_l.tl_name, LOOKUP_NOISY)) ==
RT_DIR_NULL) {
+ if (s->final_check) {
+ // If we didn't spot this object as missing in the
beginning, it indicates
+ // a problem with the push
+ if (s->initial_missing.find(std::string(tp->tr_l.tl_name))
== s->initial_missing.end()) {
+ s->valid_push = false;
+ }
+ } else {
+ // This instance is referencing a non-existent object from
the beginning,
+ // so its absence won't indicate a problem with the push
later
+ s->initial_missing.insert(std::string(tp->tr_l.tl_name));
+ }
return;
+ }
- if (s->target_objs.find(std::string(dp->d_namep)) !=
s->target_objs.end()) {
- s->valid_push = false;
- s->problem_obj = std::string(dp->d_namep);
- return;
+ if (!s->final_check) {
+ if (s->target_objs.find(std::string(dp->d_namep)) !=
s->target_objs.end()) {
+ s->valid_push = false;
+ s->problem_obj = std::string(dp->d_namep);
+ return;
+ }
}
if (!(dp->d_flags & RT_DIR_COMB)) {
@@ -1177,6 +1193,19 @@
BU_PUT(in, struct rt_db_internal);
}
+ // We've written to the database - everything should be finalized now. Do
a final
+ // validation check.
+ s.valid_push = true;
+ s.final_check = true;
+ for (s_it = s.target_objs.begin(); s_it != s.target_objs.end(); s_it++) {
+ struct directory *dp = db_lookup(dbip, s_it->c_str(), LOOKUP_NOISY);
+ validate_walk(dbip, dp, &s);
+ }
+ if (!s.valid_push) {
+ bu_vls_printf(gedp->ged_result_str, "failed to generate one or more
objects listed in pushed trees.");
+ return GED_ERROR;
+ }
+
return GED_OK;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits