Skip to main content

main_depth

Function main_depth 

Source
pub fn main_depth() -> i32
Expand description

mem); g_free (block); free_list = g_list_delete_link (free_list, l); }

  l = next;
}

}


There is a temptation to use [`main_depth()`][crate::main_depth()] to solve
problems with reentrancy. For instance, while waiting for data
to be received from the network in response to a menu item,
the menu item might be selected again. It might seem that
one could make the menu item’s callback return immediately
and do nothing if [`main_depth()`][crate::main_depth()] returns a value greater than 1.
However, this should be avoided since the user then sees selecting
the menu item do nothing. Furthermore, you’ll find yourself adding
these checks all over your code, since there are doubtless many,
many things that the user could do. Instead, you can use the
following techniques:

1. Use `gtk_widget_set_sensitive()` or modal dialogs to prevent
   the user from interacting with elements while the main
   loop is recursing.

2. Avoid main loop recursion in situations where you can’t handle
   arbitrary  callbacks. Instead, structure your code so that you
   simply return to the main loop and then get called again when
   there is more work to do.

# Returns

the main loop recursion level in the current thread