diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 5677fd7..25582ee 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -9894,13 +9894,18 @@ static void
 gtk_widget_buildable_set_name (GtkBuildable *buildable,
 			       const gchar  *name)
 {
-  gtk_widget_set_name (GTK_WIDGET (buildable), name);
+  GtkWidget *widget = GTK_WIDGET (buildable);
+  if (!widget->name)
+    gtk_widget_set_name (widget, name);
+  else
+    g_object_set_data (G_OBJECT (buildable), "gtk-builder-name", name);
 }
 
 static const gchar *
 gtk_widget_buildable_get_name (GtkBuildable *buildable)
 {
-  return gtk_widget_get_name (GTK_WIDGET (buildable));
+  const gchar* name = g_object_get_data (G_OBJECT (buildable), "gtk-builder-name");
+  return name ? name : gtk_widget_get_name (GTK_WIDGET (buildable));
 }
 
 static GObject *
