Bugfix: Fix several bugs in table_cleanup()
This commit is contained in:
parent
23e92f2e6d
commit
3090f03ed2
32
src/table.c
32
src/table.c
|
@ -107,11 +107,22 @@ bool cell_exists(int col, int row) {
|
||||||
static void move_columns_from(Workspace *workspace, int cols) {
|
static void move_columns_from(Workspace *workspace, int cols) {
|
||||||
for (; cols < workspace->cols; cols++)
|
for (; cols < workspace->cols; cols++)
|
||||||
for (int rows = 0; rows < workspace->rows; rows++) {
|
for (int rows = 0; rows < workspace->rows; rows++) {
|
||||||
free(workspace->table[cols-1][rows]);
|
Container *old_container = workspace->table[cols-1][rows],
|
||||||
|
*new_container = workspace->table[cols][rows];
|
||||||
|
|
||||||
|
/* Fix the container backpointer for all clients */
|
||||||
|
Client *client;
|
||||||
|
CIRCLEQ_FOREACH(client, &(old_container->clients), clients)
|
||||||
|
client->container = new_container;
|
||||||
|
|
||||||
|
free(old_container);
|
||||||
|
|
||||||
printf("moving cols = %d to cols -1 = %d\n", cols, cols-1);
|
printf("moving cols = %d to cols -1 = %d\n", cols, cols-1);
|
||||||
workspace->table[cols-1][rows] = workspace->table[cols][rows];
|
workspace->table[cols-1][rows] = new_container;
|
||||||
workspace->table[cols-1][rows]->col--;
|
|
||||||
|
new_container->row = rows;
|
||||||
|
new_container->col = cols-1;
|
||||||
|
|
||||||
workspace->table[cols][rows] = NULL;
|
workspace->table[cols][rows] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,11 +130,20 @@ static void move_columns_from(Workspace *workspace, int cols) {
|
||||||
static void move_rows_from(Workspace *workspace, int rows) {
|
static void move_rows_from(Workspace *workspace, int rows) {
|
||||||
for (; rows < workspace->rows; rows++)
|
for (; rows < workspace->rows; rows++)
|
||||||
for (int cols = 0; cols < workspace->cols; cols++) {
|
for (int cols = 0; cols < workspace->cols; cols++) {
|
||||||
free(workspace->table[cols][rows-1]);
|
Container *old_container = workspace->table[cols][rows-1],
|
||||||
|
*new_container = workspace->table[cols][rows];
|
||||||
|
|
||||||
|
/* Fix the container backpointer for all clients */
|
||||||
|
Client *client;
|
||||||
|
CIRCLEQ_FOREACH(client, &(old_container->clients), clients)
|
||||||
|
client->container = new_container;
|
||||||
|
|
||||||
|
free(old_container);
|
||||||
|
|
||||||
printf("moving rows = %d to rows -1 = %d\n", rows, rows - 1);
|
printf("moving rows = %d to rows -1 = %d\n", rows, rows - 1);
|
||||||
workspace->table[cols][rows-1] = workspace->table[cols][rows];
|
workspace->table[cols][rows-1] = new_container;
|
||||||
workspace->table[cols][rows-1]->row--;
|
new_container->row = rows-1;
|
||||||
|
new_container->col = cols;
|
||||||
workspace->table[cols][rows] = NULL;
|
workspace->table[cols][rows] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue