Merge lp:~bregma/geis/lp-824101 into lp:geis

Proposed by Stephen M. Webb
Status: Merged
Merged at revision: 201
Proposed branch: lp:~bregma/geis/lp-824101
Merge into: lp:geis
Diff against target: 127 lines (+13/-75)
1 file modified
testsuite/geistest/geistest.c (+13/-75)
To merge this branch: bzr merge lp:~bregma/geis/lp-824101
Reviewer Review Type Date Requested Status
Chase Douglas (community) Approve
Review via email: mp+93049@code.launchpad.net

Description of the change

Prevents the geistest tool from crashing when run without explicitly specifying a window by watching the root window(s) instead of walking the entire window heirarchy.

Fixes lp:824101.

To post a comment you must log in.
Revision history for this message
Chase Douglas (chasedouglas) wrote :

I would change the function "subscribe_all_windows" to "subscribe_all_root_windows" so it's more clear what is going on. I think this is a good change :).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testsuite/geistest/geistest.c'
2--- testsuite/geistest/geistest.c 2011-08-17 15:48:51 +0000
3+++ testsuite/geistest/geistest.c 2012-02-14 19:03:08 +0000
4@@ -280,67 +280,7 @@
5 }
6
7
8-static size_t
9-subscribe_windows_preorder(xcb_connection_t *xcb,
10- xcb_window_t window,
11- size_t instance_table_size,
12- GeisInstance **instance_table)
13-{
14- ++instance_table_size;
15- GeisInstance *new_instance_table;
16- new_instance_table = realloc(*instance_table,
17- instance_table_size * sizeof(GeisInstance));
18- new_instance_table[instance_table_size-1] = subscribe_window(window);
19- if (!new_instance_table[instance_table_size-1])
20- {
21- fprintf(stderr, "error creating geis instance for window 0x%08x\n", window);
22- free(new_instance_table);
23- instance_table_size = 0;
24- goto error_exit;
25- }
26-
27- xcb_generic_error_t *error;
28- xcb_query_tree_cookie_t tree_cookie = xcb_query_tree(xcb, window);
29- xcb_query_tree_reply_t *tree_reply = xcb_query_tree_reply(xcb,
30- tree_cookie,
31- &error);
32- if (!tree_reply)
33- {
34- fprintf(stderr, "failed to query tree for window 0x%x\n", window);
35- goto error_exit;
36- }
37-
38- int num_children = xcb_query_tree_children_length(tree_reply);
39- if (num_children <= 0)
40- goto tree_exit;
41-
42- xcb_window_t *children = xcb_query_tree_children(tree_reply);
43- if (!children)
44- {
45- fprintf(stderr, "failed to retrieve children of window 0x%x\n", window);
46- goto tree_exit;
47- }
48-
49- int i;
50- for (i = 0; i < num_children; i++)
51- {
52- instance_table_size = subscribe_windows_preorder(xcb,
53- children[i],
54- instance_table_size,
55- &new_instance_table);
56- if (instance_table_size == 0)
57- break;
58- }
59-
60-tree_exit:
61- free(tree_reply);
62-error_exit:
63- *instance_table = new_instance_table;
64- return instance_table_size;
65-}
66-
67-
68-static size_t
69+static void
70 subscribe_all_windows(GeisInstance **instance_table)
71 {
72 int instance_table_size = 0;
73@@ -348,29 +288,32 @@
74 xcb_connection_t *xcb = xcb_connect(NULL, NULL);
75 if (!xcb) {
76 fprintf(stderr, "error connecting to X server\n");
77- return -1;
78+ exit(1);
79 }
80
81 const xcb_setup_t *setup = xcb_get_setup(xcb);
82 if (!setup)
83 {
84 fprintf(stderr, "error getting xcb setup\n");
85- return -1;
86+ exit(1);
87 }
88
89 xcb_screen_iterator_t screen = xcb_setup_roots_iterator(setup);
90 while (screen.rem)
91 {
92- instance_table_size = subscribe_windows_preorder(xcb,
93- screen.data->root,
94- instance_table_size,
95- instance_table);
96-
97+ ++instance_table_size;
98 xcb_screen_next(&screen);
99 }
100
101+ *instance_table = calloc(instance_table_size, sizeof(GeisInstance));
102+
103+ screen = xcb_setup_roots_iterator(setup);
104+ for (int i = 0; screen.rem; ++i, xcb_screen_next(&screen))
105+ {
106+ *instance_table[i] = subscribe_window(screen.data->root);
107+ }
108+
109 xcb_disconnect(xcb);
110- return instance_table_size;
111 }
112
113 int
114@@ -402,12 +345,7 @@
115 }
116 else
117 {
118- instance_table_size = subscribe_all_windows(&instance_table);
119- if (instance_table_size == 0)
120- {
121- fprintf(stderr, "can not continue, exiting....\n");
122- goto error_exit;
123- }
124+ subscribe_all_windows(&instance_table);
125 }
126
127 status = geis_configuration_supported(instance_table[0], GEIS_CONFIG_UNIX_FD);

Subscribers

People subscribed via source and target branches