From d68171ebaceaa1b6ead605e9cd5bb68c680ccd8a Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Tue, 20 Jun 2017 11:28:09 +0200 Subject: src/prompt-box.vala: Avoid 'pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed' error. --- src/prompt-box.vala | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/prompt-box.vala') diff --git a/src/prompt-box.vala b/src/prompt-box.vala index 6d5bc13..9901d4f 100644 --- a/src/prompt-box.vala +++ b/src/prompt-box.vala @@ -374,7 +374,23 @@ public class PromptBox : FadableBox public void clear () { prompt_visibility = PromptVisibility.HIDDEN; - foreach_prompt_widget ((w) => { w.destroy (); }); + + /* Hold a ref while removing the prompt widgets - + * if we just do w.destroy() we get this warning: + * CRITICAL: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed + * by GtkWidget's screen-changed signal being called on + * widget when we destroy it. + */ + foreach_prompt_widget ((w) => { +#if HAVE_GTK_3_20_0 + w.ref (); + w.get_parent().remove(w); + w.unref (); +#else + w.destroy (); +#endif + }); + reset_last_row (); has_errors = false; } -- cgit v1.2.3