My UI is bound to a specific instance of GSettings
(let’s call it mysettings
). I have a different thread that will need to read some of those settings (via g_settings_get_value
): is it safe to pass mysettings
to the thread? If not, what is the suggested approach? Create two different instances and pass one to the thread?
GSettings
is not thread-safe, so you should use a different GSettings
instance per thread. You should create the instance for each thread in that thread itself, as signal emissions from GSettings
are done in the thread where the GSettings
object was created. (Assuming you have one GMainContext
per thread.)
In general, nothing in GLib/GIO is thread-safe unless explicitly stated.
1 Like
Good to know: thank you for the info.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.