1#include <gtk/gtk.h>
2
3static gboolean
4main_loop_quit_cb (gpointer data)
5{
6 gboolean *done = data;
7
8 *done = TRUE;
9
10 g_main_context_wakeup (NULL);
11
12 return FALSE;
13}
14
15static void
16show_and_wait (GtkWidget *widget)
17{
18 gboolean done = FALSE;
19
20 g_timeout_add (interval: 500, function: main_loop_quit_cb, data: &done);
21 gtk_widget_show (widget);
22 while (!done)
23 g_main_context_iteration (NULL, FALSE);
24}
25
26/* this was triggering a crash in gtk_flow_box_measure(),
27 * see #2702
28 */
29static void
30test_measure_crash (void)
31{
32 GtkWidget *window, *box, *child;
33
34 window = gtk_window_new ();
35 box = gtk_flow_box_new ();
36 gtk_widget_set_valign (GTK_WIDGET (box), align: GTK_ALIGN_START);
37 child = g_object_new (GTK_TYPE_FLOW_BOX_CHILD,
38 first_property_name: "css-name", "nopadding",
39 NULL);
40 gtk_flow_box_insert (GTK_FLOW_BOX (box), widget: child, position: -1);
41 gtk_orientable_set_orientation (GTK_ORIENTABLE (box), orientation: GTK_ORIENTATION_VERTICAL);
42 gtk_flow_box_set_row_spacing (GTK_FLOW_BOX (box), spacing: 0);
43
44 gtk_window_set_child (GTK_WINDOW (window), child: box);
45
46 show_and_wait (widget: window);
47
48 gtk_window_destroy (GTK_WINDOW (window));
49}
50
51int
52main (int argc, char *argv[])
53{
54 gtk_test_init (argcp: &argc, argvp: &argv);
55
56 g_test_add_func (testpath: "/flowbox/measure-crash", test_func: test_measure_crash);
57
58 return g_test_run ();
59}
60

source code of gtk/testsuite/gtk/flowbox.c