Commit 19b534f7 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Avoid copying static debug strings

The g_source_set_name calls were showing up as a
major source of strdups in our profiles. Avoid that
by using new GLib api when available.
parent 910f23ea
......@@ -33,6 +33,7 @@
#include "gdkinternals.h"
#include "gdkdeviceprivate.h"
#include <gdk/gdktextureprivate.h>
#include "gdk-private.h"
#include <glib.h>
#include <glib/gprintf.h>
......@@ -463,7 +464,7 @@ gdk_broadway_display_flush_in_idle (GdkDisplay *display)
if (broadway_display->idle_flush_id == 0)
{
broadway_display->idle_flush_id = g_idle_add (flush_idle, g_object_ref (display));
g_source_set_name_by_id (broadway_display->idle_flush_id, "[gtk] flush_idle");
gdk_source_set_static_name_by_id (broadway_display->idle_flush_id, "[gtk] flush_idle");
}
}
......
......@@ -57,4 +57,11 @@ guint gdk_parse_debug_var (const char *variable,
# define g_memdup2(mem,size) g_memdup((mem),(size))
#endif
void gdk_source_set_static_name_by_id (guint tag,
const char *name);
#if !GLIB_CHECK_VERSION(2, 69, 1)
#define g_source_set_static_name(source, name) g_source_set_name ((source), (name))
#endif
#endif /* __GDK__PRIVATE_H__ */
......@@ -414,3 +414,17 @@ gdk_find_base_dir (const char *text,
return dir;
}
void
gdk_source_set_static_name_by_id (guint tag,
const char *name)
{
GSource *source;
g_return_if_fail (tag > 0);
source = g_main_context_find_source_by_id (NULL, tag);
if (source == NULL)
return;
g_source_set_static_name (source, name);
}
......@@ -29,6 +29,7 @@
#include "gdkinternals.h"
#include "gdkframeclockprivate.h"
#include "gdk.h"
#include "gdk-private.h"
#include "gdkprofilerprivate.h"
#ifdef G_OS_WIN32
......@@ -307,12 +308,15 @@ maybe_start_idle (GdkFrameClockIdle *clock_idle,
if (priv->flush_idle_id == 0 && RUN_FLUSH_IDLE (priv))
{
GSource *source;
priv->flush_idle_id = g_timeout_add_full (GDK_PRIORITY_EVENTS + 1,
min_interval,
gdk_frame_clock_flush_idle,
g_object_ref (clock_idle),
(GDestroyNotify) g_object_unref);
g_source_set_name_by_id (priv->flush_idle_id, "[gtk] gdk_frame_clock_flush_idle");
source = g_main_context_find_source_by_id (NULL, priv->flush_idle_id);
g_source_set_static_name (source, "[gtk] gdk_frame_clock_flush_idle");
}
if (!priv->in_paint_idle &&
......@@ -324,7 +328,7 @@ maybe_start_idle (GdkFrameClockIdle *clock_idle,
gdk_frame_clock_paint_idle,
g_object_ref (clock_idle),
(GDestroyNotify) g_object_unref);
g_source_set_name_by_id (priv->paint_idle_id, "[gtk] gdk_frame_clock_paint_idle");
gdk_source_set_static_name_by_id (priv->paint_idle_id, "[gtk] gdk_frame_clock_paint_idle");
}
}
}
......
......@@ -197,7 +197,7 @@ gdk_display_link_source_new (void)
gdk_display_link_source_frame_cb,
source);
g_source_set_name (source, "[gdk] quartz frame clock");
g_source_set_static_name (source, "[gdk] quartz frame clock");
return source;
}
......
......@@ -21,6 +21,7 @@
#include "gdkdeviceprivate.h"
#include "gdkintl.h"
#include "gdk-private.h"
#include "gdkmacosdevice-private.h"
#include "gdkmacoscursor-private.h"
......@@ -161,7 +162,7 @@ gdk_macos_drag_drop_done (GdkDrag *drag,
gdk_macos_zoomback_timeout,
zb,
(GDestroyNotify) gdk_macos_zoomback_destroy);
g_source_set_name_by_id (id, "[gtk] gdk_macos_zoomback_timeout");
gdk_source_set_static_name_by_id (id, "[gtk] gdk_macos_zoomback_timeout");
g_object_unref (drag);
}
......
......@@ -1063,7 +1063,7 @@ _gdk_macos_event_source_new (GdkMacosDisplay *display)
event_poll_fd.fd = -1;
source = g_source_new (&event_funcs, sizeof (GdkMacosEventSource));
g_source_set_name (source, "GDK Quartz event source");
g_source_set_static_name (source, "GDK Quartz event source");
g_source_add_poll (source, &event_poll_fd);
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
g_source_set_can_recurse (source, TRUE);
......
......@@ -460,6 +460,7 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
pointer->cursor_timeout_id == 0)
{
guint id;
GSource *source;
gdk_wayland_pointer_stop_cursor_animation (pointer);
......@@ -467,7 +468,8 @@ gdk_wayland_device_update_surface_cursor (GdkDevice *device)
id = g_timeout_add (next_image_delay,
(GSourceFunc) gdk_wayland_device_update_surface_cursor,
device);
g_source_set_name_by_id (id, "[gtk] gdk_wayland_device_update_surface_cursor");
source = g_main_context_find_source_by_id (NULL, id);
g_source_set_static_name (source, "[gtk] gdk_wayland_device_update_surface_cursor");
pointer->cursor_timeout_id = id;
}
else
......@@ -2218,7 +2220,7 @@ deliver_key_event (GdkWaylandSeat *seat,
timeout = (seat->repeat_deadline - now) / 1000L;
seat->repeat_timer = g_timeout_add (timeout, keyboard_repeat, seat);
g_source_set_name_by_id (seat->repeat_timer, "[gtk] keyboard_repeat");
gdk_source_set_static_name_by_id (seat->repeat_timer, "[gtk] keyboard_repeat");
}
static void
......
......@@ -27,6 +27,8 @@
#include "config.h"
#include <string.h>
#include "gdk-private.h"
#include <io.h>
#include <fcntl.h>
#include <math.h>
......@@ -2196,7 +2198,7 @@ gdk_win32_drag_drop_done (GdkDrag *drag,
id = g_timeout_add_full (G_PRIORITY_DEFAULT, 17,
gdk_drag_anim_timeout, anim,
(GDestroyNotify) gdk_drag_anim_destroy);
g_source_set_name_by_id (id, "[gtk] gdk_drag_anim_timeout");
gdk_source_set_static_name_by_id (id, "[gtk] gdk_drag_anim_timeout");
}
static gboolean
......
......@@ -61,6 +61,7 @@
#include "gdkdisplay-win32.h"
//#include "gdkselection-win32.h"
#include "gdkdragprivate.h"
#include "gdk-private.h"
#include <windowsx.h>
......@@ -502,7 +503,7 @@ _gdk_events_init (GdkDisplay *display)
#endif
source = g_source_new (&event_funcs, sizeof (GdkWin32EventSource));
g_source_set_name (source, "GDK Win32 event source");
g_source_set_static_name (source, "GDK Win32 event source");
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
event_source = (GdkWin32EventSource *)source;
......
......@@ -25,6 +25,7 @@
#include "gdkintl.h"
#include "gdkprivate-x11.h"
#include "gdkdisplay-x11.h"
#include "gdk-private.h"
#include <glib.h>
#ifdef HAVE_DESKTOPAPPINFO
......@@ -219,7 +220,7 @@ startup_timeout (void *data)
std->timeout_id = 0;
else {
std->timeout_id = g_timeout_add_seconds ((min_timeout + 500)/1000, startup_timeout, std);
g_source_set_name_by_id (std->timeout_id, "[gtk] startup_timeout");
gdk_source_set_static_name_by_id (std->timeout_id, "[gtk] startup_timeout");
}
/* always remove this one, but we may have reinstalled another one. */
......@@ -256,7 +257,7 @@ add_startup_timeout (GdkX11Screen *screen,
if (data->timeout_id == 0) {
data->timeout_id = g_timeout_add_seconds (STARTUP_TIMEOUT_LENGTH_SECONDS,
startup_timeout, data);
g_source_set_name_by_id (data->timeout_id, "[gtk] startup_timeout");
gdk_source_set_static_name_by_id (data->timeout_id, "[gtk] startup_timeout");
}
}
......
......@@ -46,6 +46,7 @@ in this Software without prior written authorization from The Open Group.
#include "gdkasync.h"
#include "gdkprivate-x11.h"
#include "gdkdisplay-x11.h"
#include "gdk-private.h"
#include <X11/Xlibint.h>
......@@ -171,7 +172,7 @@ send_event_handler (Display *dpy,
{
guint id;
id = g_idle_add (callback_idle, state);
g_source_set_name_by_id (id, "[gtk] callback_idle");
gdk_source_set_static_name_by_id (id, "[gtk] callback_idle");
}
DeqAsyncHandler(state->dpy, &state->async);
......@@ -707,7 +708,7 @@ roundtrip_handler (Display *dpy,
{
guint id;
id = g_idle_add (roundtrip_callback_idle, state);
g_source_set_name_by_id (id, "[gtk] roundtrip_callback_idle");
gdk_source_set_static_name_by_id (id, "[gtk] roundtrip_callback_idle");
}
DeqAsyncHandler(state->dpy, &state->async);
......
......@@ -1864,7 +1864,7 @@ gdk_x11_drag_drop_done (GdkDrag *drag,
id = g_timeout_add_full (G_PRIORITY_DEFAULT, 17,
gdk_drag_anim_timeout, anim,
(GDestroyNotify) gdk_drag_anim_destroy);
g_source_set_name_by_id (id, "[gtk] gdk_drag_anim_timeout");
gdk_source_set_static_name_by_id (id, "[gtk] gdk_drag_anim_timeout");
g_object_unref (drag);
}
......
......@@ -30,6 +30,7 @@
#include "gtkdebug.h"
#include "gtkwindow.h"
#include "gtkprivate.h"
#include "a11y/atspi/atspi-accessible.h"
#include "a11y/atspi/atspi-application.h"
......@@ -612,7 +613,7 @@ gtk_at_spi_root_queue_register (GtkAtSpiRoot *self,
return;
self->register_id = g_idle_add (root_register, self);
g_source_set_name_by_id (self->register_id, "[gtk] ATSPI root registration");
gdk_source_set_static_name_by_id (self->register_id, "[gtk] ATSPI root registration");
}
void
......
......@@ -791,7 +791,7 @@ gtk_real_button_activate (GtkButton *button)
if (gtk_widget_get_realized (widget) && !priv->activate_timeout)
{
priv->activate_timeout = g_timeout_add (ACTIVATE_TIMEOUT, button_activate_timeout, button);
g_source_set_name_by_id (priv->activate_timeout, "[gtk] button_activate_timeout");
gdk_source_set_static_name_by_id (priv->activate_timeout, "[gtk] button_activate_timeout");
gtk_widget_add_css_class (GTK_WIDGET (button), "keyboard-activating");
priv->button_down = TRUE;
......
......@@ -1016,7 +1016,7 @@ gtk_emoji_chooser_init (GtkEmojiChooser *chooser)
populate_recent_section (chooser);
chooser->populate_idle = g_idle_add (populate_emoji_chooser, chooser);
g_source_set_name_by_id (chooser->populate_idle, "[gtk] populate_emoji_chooser");
gdk_source_set_static_name_by_id (chooser->populate_idle, "[gtk] populate_emoji_chooser");
}
static void
......
......@@ -1982,7 +1982,7 @@ gtk_entry_completion_changed (GtkWidget *widget,
g_timeout_add (COMPLETION_TIMEOUT,
gtk_entry_completion_timeout,
completion);
g_source_set_name_by_id (completion->completion_timeout, "[gtk] gtk_entry_completion_timeout");
gdk_source_set_static_name_by_id (completion->completion_timeout, "[gtk] gtk_entry_completion_timeout");
}
static gboolean
......@@ -2048,7 +2048,7 @@ completion_inserted_text_callback (GtkEntryBuffer *buffer,
g_cclosure_new_object (G_CALLBACK (check_completion_callback),
G_OBJECT (completion)));
g_source_attach (completion->check_completion_idle, NULL);
g_source_set_name (completion->check_completion_idle, "[gtk] check_completion_callback");
g_source_set_static_name (completion->check_completion_idle, "[gtk] check_completion_callback");
}
}
......
......@@ -244,7 +244,7 @@ gtk_expander_drag_enter (GtkDropControllerMotion *motion,
if (!expander->expanded && !expander->expand_timer)
{
expander->expand_timer = g_timeout_add (TIMEOUT_EXPAND, (GSourceFunc) expand_timeout, expander);
g_source_set_name_by_id (expander->expand_timer, "[gtk] expand_timeout");
gdk_source_set_static_name_by_id (expander->expand_timer, "[gtk] expand_timeout");
}
}
......
......@@ -2234,7 +2234,7 @@ location_entry_changed_cb (GtkEditable *editable,
impl->location_changed_id = g_timeout_add (LOCATION_CHANGED_TIMEOUT,
location_changed_timeout_cb,
impl);
g_source_set_name_by_id (impl->location_changed_id, "[gtk] location_changed_timeout_cb");
gdk_source_set_static_name_by_id (impl->location_changed_id, "[gtk] location_changed_timeout_cb");
}
}
......@@ -3822,7 +3822,7 @@ load_setup_timer (GtkFileChooserWidget *impl)
g_assert (impl->load_state != LOAD_PRELOAD);
impl->load_timeout_id = g_timeout_add (MAX_LOADING_TIME, load_timeout_cb, impl);
g_source_set_name_by_id (impl->load_timeout_id, "[gtk] load_timeout_cb");
gdk_source_set_static_name_by_id (impl->load_timeout_id, "[gtk] load_timeout_cb");
impl->load_state = LOAD_PRELOAD;
}
......
......@@ -30,6 +30,7 @@
#include "gtktreednd.h"
#include "gtktreemodel.h"
#include "gtkfilter.h"
#include "gtkprivate.h"
/*** Structure: how GtkFileSystemModel works
*
......@@ -1095,7 +1096,7 @@ gtk_file_system_model_got_files (GObject *object, GAsyncResult *res, gpointer da
thaw_func,
model,
NULL);
g_source_set_name_by_id (model->dir_thaw_source, "[gtk] thaw_func");
gdk_source_set_static_name_by_id (model->dir_thaw_source, "[gtk] thaw_func");
}
for (walk = files; walk; walk = walk->next)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment