Fix possible W->client = NULL in generated client funcs

This commit is contained in:
Martin Duquesnoy 2011-09-21 22:20:33 +02:00
parent 68aecac27c
commit 07014979c1
3 changed files with 21 additions and 19 deletions

View File

@ -22,20 +22,22 @@ void uicb_client_resize_##D(Uicb cmd) \
client_fac_resize(W->client, D, ATOI(cmd)); \ client_fac_resize(W->client, D, ATOI(cmd)); \
} }
#define CLIENT_ACTION_DIR(A, D) \ #define CLIENT_ACTION_DIR(A, D) \
void uicb_client_##A##_##D(Uicb cmd) \ void uicb_client_##A##_##D(Uicb cmd) \
{ \ { \
(void)cmd; \ (void)cmd; \
if(W->client) \ struct client *c; \
client_##A(client_next_with_pos(W->client, D)); \ if(W->client && (c = client_next_with_pos(W->client, D))) \
client_##A(c); \
} }
#define CLIENT_ACTION_LIST(A, L) \ #define CLIENT_ACTION_LIST(A, L) \
void uicb_client_##A##_##L(Uicb cmd) \ void uicb_client_##A##_##L(Uicb cmd) \
{ \ { \
(void)cmd; \ (void)cmd; \
if(W->client) \ struct client *c; \
client_##A(client_##L(W->client)); \ if(W->client && (c = client_##L(W->client))) \
client_##A(c); \
} }
/* uicb_client_resize_dir() */ /* uicb_client_resize_dir() */
@ -122,7 +124,7 @@ client_next_with_pos(struct client *bc, Position p)
{ {
struct client *c; struct client *c;
int x, y; int x, y;
const static char scanfac[PositionLast] = { +10, -10, 0, 0 }; const static char scanfac[PositionLast] = { +1, -1, 0, 0 };
/* /*
* Set start place of pointer (edge with position * Set start place of pointer (edge with position
@ -421,7 +423,6 @@ client_remove(struct client *c)
XSetErrorHandler(wmfs_error_handler); XSetErrorHandler(wmfs_error_handler);
free(c); free(c);
c = NULL;
} }
void void

View File

@ -54,10 +54,11 @@ client_next(struct client *c)
static inline struct client* static inline struct client*
client_prev(struct client *c) client_prev(struct client *c)
{ {
struct client *nc, *cc = SLIST_FIRST(&c->tag->clients); struct client *cc;
while((nc = SLIST_NEXT(cc, tnext)) && nc != c) for(cc = SLIST_FIRST(&c->tag->clients);
cc = nc; SLIST_NEXT(cc, tnext) && SLIST_NEXT(cc, tnext) != c;
cc = SLIST_NEXT(cc, tnext));
return cc; return cc;
} }

View File

@ -91,10 +91,10 @@ tag_client(struct tag *t, struct client *c)
layout_split_arrange_closed(c); layout_split_arrange_closed(c);
SLIST_REMOVE(&c->tag->clients, c, client, tnext);
if(c->tag->sel == c || W->client == c) if(c->tag->sel == c || W->client == c)
client_focus(client_next(c)); client_focus(client_next(c));
SLIST_REMOVE(&c->tag->clients, c, client, tnext);
} }
/* /*