Skip to content

Commit

Permalink
entry completion: add checks that entry is set already
Browse files Browse the repository at this point in the history
If any of the APIs that assumes that the entry is set already is used
before having one already set, things break pretty badly.

Fixes a downstream issue reported at gtk-rs/gtk4-rs#873
  • Loading branch information
bilelmoussaoui committed Feb 8, 2022
1 parent c6d5816 commit 883e832
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gtk/gtkentrycompletion.c
Expand Up @@ -1211,6 +1211,8 @@ gtk_entry_completion_match_selected (GtkEntryCompletion *completion,
GtkTreeModel *model,
GtkTreeIter *iter)
{
g_assert (completion->entry != NULL);

char *str = NULL;

gtk_tree_model_get (model, iter, completion->text_column, &str, -1);
Expand All @@ -1229,6 +1231,8 @@ gtk_entry_completion_cursor_on_match (GtkEntryCompletion *completion,
GtkTreeModel *model,
GtkTreeIter *iter)
{
g_assert (completion->entry != NULL);

gtk_entry_completion_insert_completion (completion, model, iter);

return TRUE;
Expand Down Expand Up @@ -1317,6 +1321,8 @@ static gboolean
gtk_entry_completion_real_insert_prefix (GtkEntryCompletion *completion,
const char *prefix)
{
g_assert (completion->entry != NULL);

if (prefix)
{
int key_len;
Expand Down Expand Up @@ -1417,6 +1423,8 @@ gtk_entry_completion_insert_completion (GtkEntryCompletion *completion,
void
gtk_entry_completion_insert_prefix (GtkEntryCompletion *completion)
{
g_return_if_fail (completion->entry != NULL);

gboolean done;
char *prefix;
GtkText *text = gtk_entry_get_text_widget (GTK_ENTRY (completion->entry));
Expand Down

0 comments on commit 883e832

Please sign in to comment.