Fix regression: Don’t add floating nodes twice when restoring layout (+testcase)

This commit is contained in:
Michael Stapelberg 2011-02-28 20:44:23 +01:00
parent d80105103c
commit b595ff05c5
2 changed files with 27 additions and 3 deletions

View File

@ -22,18 +22,18 @@ struct Match *current_swallow;
static int json_start_map(void *ctx) { static int json_start_map(void *ctx) {
LOG("start of map, last_key = %s\n", last_key); LOG("start of map, last_key = %s\n", last_key);
if (parsing_swallows) { if (parsing_swallows) {
LOG("TODO: create new swallow\n"); LOG("creating new swallow\n");
current_swallow = smalloc(sizeof(Match)); current_swallow = smalloc(sizeof(Match));
match_init(current_swallow); match_init(current_swallow);
TAILQ_INSERT_TAIL(&(json_node->swallow_head), current_swallow, matches); TAILQ_INSERT_TAIL(&(json_node->swallow_head), current_swallow, matches);
} else { } else {
if (!parsing_rect && !parsing_window_rect && !parsing_geometry) { if (!parsing_rect && !parsing_window_rect && !parsing_geometry) {
if (last_key && strcasecmp(last_key, "floating_nodes") == 0) { if (last_key && strcasecmp(last_key, "floating_nodes") == 0) {
DLOG("New floating_node\n");
Con *ws = con_get_workspace(json_node); Con *ws = con_get_workspace(json_node);
json_node = con_new(NULL); json_node = con_new(NULL);
json_node->parent = ws; json_node->parent = ws;
TAILQ_INSERT_TAIL(&(ws->floating_head), json_node, floating_windows); DLOG("Parent is workspace = %p\n", ws);
TAILQ_INSERT_TAIL(&(ws->focus_head), json_node, focused);
} else { } else {
Con *parent = json_node; Con *parent = json_node;
json_node = con_new(NULL); json_node = con_new(NULL);

View File

@ -0,0 +1,24 @@
#!perl
# vim:ts=4:sw=4:expandtab
#
# Regression: floating windows are tiling after restarting, closing them crashes i3
#
use i3test tests => 1;
use Time::HiRes qw(sleep);
use X11::XCB qw(:all);
my $tmp = get_unused_workspace();
cmd "workspace $tmp";
cmd 'open';
cmd 'mode toggle';
cmd 'restart';
sleep 0.5;
diag('Checking if i3 still lives');
does_i3_live;
my $ws = get_ws($tmp);
diag('ws = ' . Dumper($ws));