From 75045f052a5bc00fc8ffe35514c60e2f1611c9e9 Mon Sep 17 00:00:00 2001 From: Chris Davis Date: Fri, 27 Jun 2014 18:01:36 -0700 Subject: regedit: reopen parent keys when adding or removing subkeys This clears any cache associated with the parent key, and ensures the changes will be noticed by the UI. Signed-off-by: Chris Davis Reviewed-by: Andreas Schneider Reviewed-by: Michael Adam --- source3/utils/regedit.c | 5 +++++ source3/utils/regedit_treeview.c | 9 +++++++++ source3/utils/regedit_treeview.h | 1 + 3 files changed, 15 insertions(+) (limited to 'source3/utils') diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c index 471f875db2..b006fac848 100644 --- a/source3/utils/regedit.c +++ b/source3/utils/regedit.c @@ -230,6 +230,10 @@ static void add_reg_key(struct regedit *regedit, struct tree_node *node, name, new_key); SMB_ASSERT(new_node); tree_node_insert_sorted(list, new_node); + } else { + /* Reopen the parent key to make sure the + new subkey will be noticed. */ + tree_node_reopen_key(parent); } list = tree_node_first(node); @@ -419,6 +423,7 @@ static void handle_tree_input(struct regedit *regedit, int c) rv = reg_key_del(node, parent->key, node->name); if (W_ERROR_IS_OK(rv)) { + tree_node_reopen_key(parent); tree_view_clear(regedit->keys); pop = tree_node_pop(&node); tree_node_free_recursive(pop); diff --git a/source3/utils/regedit_treeview.c b/source3/utils/regedit_treeview.c index c8a65965bc..3af3c8b59c 100644 --- a/source3/utils/regedit_treeview.c +++ b/source3/utils/regedit_treeview.c @@ -141,6 +141,15 @@ static uint32_t get_num_subkeys(struct tree_node *node) return 0; } +WERROR tree_node_reopen_key(struct tree_node *node) +{ + SMB_ASSERT(node->parent != NULL); + SMB_ASSERT(node->name != NULL); + TALLOC_FREE(node->key); + return reg_open_key(node->parent, node->parent->key, node->name, + &node->key); +} + bool tree_node_has_children(struct tree_node *node) { if (node->child_head) { diff --git a/source3/utils/regedit_treeview.h b/source3/utils/regedit_treeview.h index cd17a3c265..954bae5ec7 100644 --- a/source3/utils/regedit_treeview.h +++ b/source3/utils/regedit_treeview.h @@ -66,6 +66,7 @@ void tree_view_resize(struct tree_view *view, int nlines, int ncols, void tree_view_show(struct tree_view *view); void tree_view_clear(struct tree_view *view); WERROR tree_view_update(struct tree_view *view, struct tree_node *list); +WERROR tree_node_reopen_key(struct tree_node *node); bool tree_node_has_children(struct tree_node *node); WERROR tree_node_load_children(struct tree_node *node); void tree_node_insert_sorted(struct tree_node *list, struct tree_node *node); -- cgit