Index: trunk/src/libcschem/util_loclib.c =================================================================== --- trunk/src/libcschem/util_loclib.c (revision 10226) +++ trunk/src/libcschem/util_loclib.c (revision 10227) @@ -2,7 +2,7 @@ * COPYRIGHT * * cschem - modular/flexible schematics editor - libcschem (core library) - * Copyright (C) 2022 Tibor 'Igor2' Palinkas + * Copyright (C) 2022, 2024 Tibor 'Igor2' Palinkas * * (Supported by NLnet NGI0 PET Fund in 2022) * @@ -110,3 +110,25 @@ return 0; } + +long csch_loclib_reload_all(csch_sheet_t *sheet, csch_lib_root_t *libroot) +{ + long n, i, cnt = 0; + + for(n = 0; n < libroot->roots.used; n++) { + csch_lib_t *root = libroot->roots.array[n]; + if (strcmp(root->name, "") == 0) { + for(i = root->children.used-1; i >= 0; i--) { + csch_lib_t *l = root->children.array[i]; + if ((l != NULL) && (l->backend != NULL) && (l->backend->loc_refresh_from_ext != NULL)) { + if (l->backend->loc_refresh_from_ext(sheet, l) == 0) + cnt++; + } + } + break; + } + } + + return cnt; +} + Index: trunk/src/libcschem/util_loclib.h =================================================================== --- trunk/src/libcschem/util_loclib.h (revision 10226) +++ trunk/src/libcschem/util_loclib.h (revision 10227) @@ -2,7 +2,7 @@ * COPYRIGHT * * cschem - modular/flexible schematics editor - libcschem (core library) - * Copyright (C) 2022 Tibor 'Igor2' Palinkas + * Copyright (C) 2022, 2024 Tibor 'Igor2' Palinkas * * (Supported by NLnet NGI0 PET Fund in 2022) * @@ -44,3 +44,7 @@ failure there's no root dir in indirect. Always frees src's fields. */ int csch_loclib_get_roots(csch_lib_t **root_dir_out, csch_cgrp_t **root_grp_out, csch_lib_master_t *master, csch_sheet_t *sheet, csch_source_arg_t *src, int alloc, int *alloced); + +/* Reload all loclib entries from external libraries. Used in actions like + SymlibReloadAllLocal() */ +long csch_loclib_reload_all(csch_sheet_t *sheet, csch_lib_root_t *libroot); Index: trunk/src/sch-rnd/file_act.c =================================================================== --- trunk/src/sch-rnd/file_act.c (revision 10226) +++ trunk/src/sch-rnd/file_act.c (revision 10227) @@ -2,7 +2,7 @@ * COPYRIGHT * * cschem - modular/flexible schematics editor - sch-rnd (executable) - * Copyright (C) 2022, 2023 Tibor 'Igor2' Palinkas + * Copyright (C) 2022, 2023, 2024 Tibor 'Igor2' Palinkas * * (Supported by NLnet NGI0 PET Fund in 2022, Entrust in 2023) * @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -87,27 +88,6 @@ return 0; } -static long lib_reload_all(csch_sheet_t *sheet, csch_lib_root_t *libroot) -{ - long n, i, cnt = 0; - - for(n = 0; n < libroot->roots.used; n++) { - csch_lib_t *root = libroot->roots.array[n]; - if (strcmp(root->name, "") == 0) { - for(i = root->children.used-1; i >= 0; i--) { - csch_lib_t *l = root->children.array[i]; - if ((l != NULL) && (l->backend != NULL) && (l->backend->loc_refresh_from_ext != NULL)) { - if (l->backend->loc_refresh_from_ext(sheet, l) == 0) - cnt++; - } - } - break; - } - } - - return cnt; -} - static const char csch_acts_SymlibReloadAllLocal[] = "SymlibReloadAllLocal()"; static const char csch_acth_SymlibReloadAllLocal[] = "Replace all local symbols from a newer version of the same symbol from the symbol library"; static fgw_error_t csch_act_SymlibReloadAllLocal(fgw_arg_t *res, int argc, fgw_arg_t *argv) @@ -116,7 +96,7 @@ csch_lib_master_t *master = csch_lib_get_master("symbol", 0); long cnt; - cnt = lib_reload_all(sheet, sheet->local_libs.array[master->uid]); + cnt = csch_loclib_reload_all(sheet, sheet->local_libs.array[master->uid]); rnd_message(RND_MSG_INFO, "Reloaded %ld local lib symbol(s) from external libs\n", cnt); rnd_event(&sheet->hidlib, CSCH_EVENT_LIBRARY_CHANGED, NULL);