Skip to content

Commit

Permalink
plugins/debug: fix reparent logic
Browse files Browse the repository at this point in the history
get widget parent and hide the widget for reparenting
add reference to widget before removing from existing container
remove widget from container before adding to new one
add widget to new container

Signed-off-by: Cristina Suteu <[email protected]>
  • Loading branch information
cristina-suteu committed Jan 26, 2024
1 parent 619b5df commit 571d38d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions plugins/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,11 +1000,17 @@ static void draw_reg_map(int valid_register)
const gchar *label_str;
char buf[12];
GtkRequisition r;
GtkWidget *parent;

block_bit_option_signals();
/* Reset all bits to the "reseverd" status and clear all options */
for (i = (reg_bit_width - 1); i >= 0; i--){
gtk_container_add(GTK_CONTAINER(hboxes[i]),lbl_bits[i]);
parent = gtk_widget_get_parent(GTK_WIDGET(lbl_bits[i]));
gtk_widget_hide(GTK_WIDGET(lbl_bits[i]));
g_object_ref(GTK_WIDGET(lbl_bits[i]));
gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET(lbl_bits[i]));
gtk_container_add(GTK_CONTAINER(hboxes[i]), GTK_WIDGET(lbl_bits[i]));
gtk_widget_show(GTK_WIDGET(lbl_bits[i]));
gtk_label_set_text((GtkLabel *)bit_descrip_list[i], "Reserved");
gtk_label_set_width_chars((GtkLabel *)bit_descrip_list[i], 13);
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(bit_comboboxes[i]));
Expand Down Expand Up @@ -1046,8 +1052,13 @@ static void draw_reg_map(int valid_register)
for (i = 0; i < p_reg->bgroup_cnt; i++){
p_bit = &p_reg->bgroup_list[i];
for (j = (p_bit->width - 1); j >= 0 ; j--){
gtk_container_add(GTK_CONTAINER(hboxes[p_bit->offset]), lbl_bits[p_bit->offset + j]);
gtk_box_reorder_child((GtkBox *)hboxes[p_bit->offset], lbl_bits[p_bit->offset + j], -1);
parent = gtk_widget_get_parent(GTK_WIDGET(lbl_bits[p_bit->offset + j]));
gtk_widget_hide(GTK_WIDGET(lbl_bits[p_bit->offset + j]));
g_object_ref(GTK_WIDGET(lbl_bits[p_bit->offset + j]));
gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET(lbl_bits[p_bit->offset + j]));
gtk_container_add(GTK_CONTAINER(hboxes[p_bit->offset]), GTK_WIDGET(lbl_bits[p_bit->offset + j]));
gtk_box_reorder_child(GTK_BOX(hboxes[p_bit->offset]), GTK_WIDGET(lbl_bits[p_bit->offset + j]), -1);
gtk_widget_show(GTK_WIDGET(lbl_bits[p_bit->offset + j]));
if (j > 0)
gtk_widget_hide(elem_frames[p_bit->offset + j]);
}
Expand Down

0 comments on commit 571d38d

Please sign in to comment.