### Function

# GLib MainContext ref_thread_default

since: 2.32

#### Declaration [src]

    GMainContext*
    g_main_context_ref_thread_default (
      void
    )

#### Description [src]

Gets the thread-default `GMainContext` for this thread, as with `g_main_context_get_thread_default()`, but also adds a reference to it with `g_main_context_ref()`. In addition, unlike `g_main_context_get_thread_default()`, if the thread-default context is the global-default context, this will return that `GMainContext` (with a ref added to it) rather than returning `NULL`.

Available since: 2.32

#### Return value

Type: `GMainContext`

The thread-default `GMainContext`. Unref with `g_main_context_unref()` when you are done with it.

The caller of the function takes ownership of the data, and is responsible for freeing it.