From 35ebefdb497c9aee0b417586b0d4397e56527599 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:29:19 -0500 Subject: [PATCH] Make db_update part of the global db context. --- src/mged/cmd.c | 3 +-- src/mged/f_db.c | 2 +- src/mged/mged.c | 7 +------ src/mged/mged.h | 2 +- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/mged/cmd.c b/src/mged/cmd.c index aca8868814..49642a361e 100644 --- a/src/mged/cmd.c +++ b/src/mged/cmd.c @@ -79,7 +79,6 @@ struct cmd_list head_cmd_list; struct cmd_list *curr_cmd_list; extern int mged_db_warn; -extern int mged_db_upgrade; extern int mged_db_version; static int glob_compat_mode = 1; @@ -1646,7 +1645,7 @@ mged_global_variable_setup(struct mged_state *s) { Tcl_LinkVar(s->interp, "mged_default(dlist)", (char *)&mged_default_dlist, TCL_LINK_INT); Tcl_LinkVar(s->interp, "mged_default(db_warn)", (char *)&mged_db_warn, TCL_LINK_INT); - Tcl_LinkVar(s->interp, "mged_default(db_upgrade)", (char *)&mged_db_upgrade, TCL_LINK_INT); + Tcl_LinkVar(s->interp, "mged_default(db_upgrade)", (char *)&mged_global_db_ctx.db_upgrade, TCL_LINK_INT); Tcl_LinkVar(s->interp, "mged_default(db_version)", (char *)&mged_db_version, TCL_LINK_INT); Tcl_LinkVar(s->interp, "edit_class", (char *)&es_edclass, TCL_LINK_INT); diff --git a/src/mged/f_db.c b/src/mged/f_db.c index a9fd48afea..8da8996768 100644 --- a/src/mged/f_db.c +++ b/src/mged/f_db.c @@ -267,7 +267,7 @@ mged_post_opendb_clbk(int UNUSED(ac), const char **UNUSED(argv), void *vgedp, vo * creating a new database. */ if (db_version(s->dbip) < 5 && !mctx->created_new_db) { - if (mged_db_upgrade) { + if (mctx->db_upgrade) { if (mged_db_warn) bu_vls_printf(gedp->ged_result_str, "Warning:\n\tDatabase version is old.\n\tConverting to the new format.\n"); diff --git a/src/mged/mged.c b/src/mged/mged.c index 683a5e7c44..e1a2f2fb2a 100644 --- a/src/mged/mged.c +++ b/src/mged/mged.c @@ -163,12 +163,6 @@ int old_mged_gui=1; */ int mged_db_warn = 0; -/* - * 0 - no upgrade - * 1 - upgrade - */ -int mged_db_upgrade = 0; - /* force creation of specific database versions */ int mged_db_version = BRLCAD_DB_FORMAT_LATEST; @@ -1852,6 +1846,7 @@ main(int argc, char *argv[]) // Start out in an initialization state mged_global_db_ctx.init_flag = 1; + mged_global_db_ctx.db_upgrade = 0; // no upgrade char *attach = (char *)NULL; diff --git a/src/mged/mged.h b/src/mged/mged.h index 4668324e16..5d049cbd7e 100644 --- a/src/mged/mged.h +++ b/src/mged/mged.h @@ -139,7 +139,6 @@ struct cmdtab { #include "./menu.h" /* initialization states */ -extern int mged_db_upgrade; extern int mged_db_version; extern int mged_db_warn; @@ -443,6 +442,7 @@ struct mged_opendb_ctx { int post_open_cnt; struct mged_state *s; int init_flag; /* >0 means in initialization stage */ + int db_upgrade; /* 0 (default) no upgrade, 1 upgrade */ }; extern struct mged_opendb_ctx mged_global_db_ctx;