mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Ticket #3562: fix Glib-critical asserts in empty WListbox.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
e4badcf7bc
commit
e629712197
@ -52,7 +52,7 @@ const global_keymap_t *listbox_map = NULL;
|
|||||||
/*** file scope macro definitions ****************************************************************/
|
/*** file scope macro definitions ****************************************************************/
|
||||||
|
|
||||||
/* Gives the position of the last item. */
|
/* Gives the position of the last item. */
|
||||||
#define LISTBOX_LAST(l) (g_queue_is_empty ((l)->list) ? 0 : (int) g_queue_get_length ((l)->list) - 1)
|
#define LISTBOX_LAST(l) (listbox_is_empty (l) ? 0 : (int) g_queue_get_length ((l)->list) - 1)
|
||||||
|
|
||||||
/*** file scope type declarations ****************************************************************/
|
/*** file scope type declarations ****************************************************************/
|
||||||
|
|
||||||
@ -231,10 +231,13 @@ listbox_y_pos (WListbox * l, int y)
|
|||||||
static void
|
static void
|
||||||
listbox_fwd (WListbox * l, gboolean wrap)
|
listbox_fwd (WListbox * l, gboolean wrap)
|
||||||
{
|
{
|
||||||
if ((guint) l->pos + 1 < g_queue_get_length (l->list))
|
if (!listbox_is_empty (l))
|
||||||
listbox_select_entry (l, l->pos + 1);
|
{
|
||||||
else if (wrap)
|
if ((guint) l->pos + 1 < g_queue_get_length (l->list))
|
||||||
listbox_select_first (l);
|
listbox_select_entry (l, l->pos + 1);
|
||||||
|
else if (wrap)
|
||||||
|
listbox_select_first (l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -250,10 +253,13 @@ listbox_fwd_n (WListbox * l, int n)
|
|||||||
static void
|
static void
|
||||||
listbox_back (WListbox * l, gboolean wrap)
|
listbox_back (WListbox * l, gboolean wrap)
|
||||||
{
|
{
|
||||||
if (l->pos > 0)
|
if (!listbox_is_empty (l))
|
||||||
listbox_select_entry (l, l->pos - 1);
|
{
|
||||||
else if (wrap)
|
if (l->pos > 0)
|
||||||
listbox_select_last (l);
|
listbox_select_entry (l, l->pos - 1);
|
||||||
|
else if (wrap)
|
||||||
|
listbox_select_last (l);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -402,6 +408,9 @@ listbox_do_action (WListbox * l)
|
|||||||
{
|
{
|
||||||
int action;
|
int action;
|
||||||
|
|
||||||
|
if (listbox_is_empty (l))
|
||||||
|
return;
|
||||||
|
|
||||||
if (l->callback != NULL)
|
if (l->callback != NULL)
|
||||||
action = l->callback (l);
|
action = l->callback (l);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user