xaizek / euclid-wm (License: BSD 3-Clause) (since 2018-12-07)
A minimalist, tiling window manager for X11 that seeks to allow easy management of numerous windows entirely from the keyboard.
Commit b2a72cf798357b55d11140a4d5153842381f549e

Fix crash on forgetting a window
erase_win() followed

free(c);

with

c = c->next;

`sleep 3 && exit` in a terminal, switch to a different desktop and wait
3 seconds for euclid-wm to crash. At least this is how it started to
crash regularly for me after a system update, there were crashes before,
but nothing predictable, so maybe it was this problem.
Author: xaizek
Author date (UTC): 2021-12-04 18:32
Committer name: xaizek
Committer date (UTC): 2021-12-04 18:32
Parent(s): ee854e9db98607cdb58f43319e471bdb93fd4417
Signing key: 99DC5E4DB05F6BE2
Tree: 1d063c9bb107aae807d40ac6c6dbb426f0dbac41
File Lines added Lines deleted
euclid-wm.c 28 21
File euclid-wm.c changed (mode: 100644) (index 214b72d..3241333)
... ... struct win * add_win(Window id) {
916 916 return p; return p;
917 917 } }
918 918
919 void forget_win (Window id) {
920 //first see whether we have a record of it
921 if (first_win == NULL) {
922 fprintf(stderr,"euclid-wm: cannot remove window %6.0lx, internal data structure is corrpupt or there are not windows being managed (no first_win defined)\n",id);
923 return;
924 };
925 struct win * w = first_win;
926 struct win * w2 = first_win;
927 if (w->id != id) {
928 while (w->next != NULL && w->next->id != id) {
929 w = w->next;
930 };
931 w2 = w; //this should be the win struct before the one we are deleting
932 w = w->next;
933 };
934
935 if (w == NULL) {
936 return;
937 };
938 //we have the win struct stored in w;
919 // finds window in layout and removes it (possibly removing its parent track)
920 void erase_win (struct win * w) {
939 921 struct view *v = fv; struct view *v = fv;
940 922 struct track *t; struct track *t;
941 923 struct cont *c; struct cont *c;
 
... ... void forget_win (Window id) {
1003 985 }; };
1004 986 free(c); free(c);
1005 987 }; };
988
989 return;
1006 990 }; };
1007 991 c = c->next; c = c->next;
1008 992 }; };
 
... ... void forget_win (Window id) {
1010 994 }; };
1011 995 v = v->next; v = v->next;
1012 996 }; };
997 }
998
999 void forget_win (Window id) {
1000 //first see whether we have a record of it
1001 if (first_win == NULL) {
1002 fprintf(stderr,"euclid-wm: cannot remove window %6.0lx, internal data structure is corrpupt or there are not windows being managed (no first_win defined)\n",id);
1003 return;
1004 };
1005 struct win * w = first_win;
1006 struct win * w2 = first_win;
1007 if (w->id != id) {
1008 while (w->next != NULL && w->next->id != id) {
1009 w = w->next;
1010 };
1011 w2 = w; //this should be the win struct before the one we are deleting
1012 w = w->next;
1013 };
1014
1015 if (w == NULL) {
1016 return;
1017 };
1018
1019 erase_win(w);
1013 1020 //we also need to check the stacks: //we also need to check the stacks:
1014 v = fv;
1021 struct view *v = fv;
1015 1022 struct stack_item *s = NULL; struct stack_item *s = NULL;
1016 1023 while (v != NULL) { while (v != NULL) {
1017 1024 s = v->stack; s = v->stack;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/euclid-wm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/euclid-wm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master