Skip to content

Commit

Permalink
gtk: replace deprecated gtk_type_new and _unique
Browse files Browse the repository at this point in the history
Calling these causes segfaults.

This fix is based on
https://launchpadlibrarian.net/295253441/gmrun-tdp-patch.diff
  • Loading branch information
henning-schild authored and wdlkmpx committed Dec 3, 2017
1 parent 8f4d2fc commit 6a0ea01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions src/gtkcompletionline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,26 @@ static gboolean
on_key_press(GtkCompletionLine *cl, GdkEventKey *event, gpointer data);

/* get_type */
guint gtk_completion_line_get_type(void)
GType gtk_completion_line_get_type(void)
{
static guint type = 0;
static GType type = 0;
if (type == 0)
{
GtkTypeInfo type_info =
static const GTypeInfo type_info =
{
"GtkCompletionLine",
sizeof(GtkCompletionLine),
sizeof(GtkCompletionLineClass),
(GtkClassInitFunc)gtk_completion_line_class_init,
(GtkObjectInitFunc)gtk_completion_line_init,
/*(GtkArgSetFunc)*/NULL /* reserved */,
/*(GtkArgGetFunc)*/NULL /* reserved */
NULL,
NULL,
(GClassInitFunc)gtk_completion_line_class_init,
NULL,
NULL,
sizeof(GtkCompletionLine),
0,
(GInstanceInitFunc)gtk_completion_line_init,
NULL
};
type = gtk_type_unique(gtk_entry_get_type(), &type_info);
type = g_type_register_static(GTK_TYPE_ENTRY, "GtkCompletionLine",
&type_info, (GTypeFlags)0);
}
return type;
}
Expand Down Expand Up @@ -745,7 +749,7 @@ complete_line(GtkCompletionLine *object)
GtkWidget *
gtk_completion_line_new()
{
return GTK_WIDGET(gtk_type_new(gtk_completion_line_get_type()));
return GTK_WIDGET(g_object_new(gtk_completion_line_get_type(), NULL));
}

static void
Expand Down
2 changes: 1 addition & 1 deletion src/gtkcompletionline.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extern "C++" {
void (* cancel)(GtkCompletionLine *cl);
};

guint gtk_completion_line_get_type(void);
GType gtk_completion_line_get_type(void);
GtkWidget *gtk_completion_line_new();

void gtk_completion_line_last_history_item(GtkCompletionLine*);
Expand Down

0 comments on commit 6a0ea01

Please sign in to comment.