Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
conf.c File Reference
#include "math/calculator.h"
#include "system/atomic.h"
#include "common/paths.h"
#include "darktable.h"
#include "common/file_location.h"
#include "math/math.h"
#include "common/conf.h"
#include <glib.h>
#include <glib/gstdio.h>
#include <glib/gprintf.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "common/utility.h"
+ Include dependency graph for common/conf.c:

Go to the source code of this file.

Data Structures

struct  dt_conf_dreggn_t
 

Macros

#define LINE_SIZE   1023
 
#define CONFIG_DIR   "$(config)"
 
#define HOME_DIR   "$(home)"
 

Typedefs

typedef struct dt_conf_dreggn_t dt_conf_dreggn_t
 

Functions

static void _free_confgen_value (void *value)
 
static char * _dt_conf_get_var_locked (const char *name)
 
static char * dt_conf_get_var (const char *name)
 
uint64_t dt_conf_generation (void)
 A counter that advances whenever a conf value actually changes.
 
static int dt_conf_set_if_not_overridden (const char *name, char *str)
 
void dt_conf_set_int (const char *name, int val)
 
void dt_conf_set_int64 (const char *name, int64_t val)
 
void dt_conf_set_float (const char *name, float val)
 
void dt_conf_set_bool (const char *name, int val)
 
void dt_conf_set_string (const char *name, const char *val)
 
void dt_conf_set_folder_from_file_chooser (const char *name, GtkFileChooser *chooser)
 
int dt_conf_get_int_fast (const char *name)
 Stored integer for name, NOT clamped to its declared bounds.
 
int dt_conf_get_int (const char *name)
 Integer for name, clamped to the bounds declared in the XML.
 
int64_t dt_conf_get_int64_fast (const char *name)
 Stored 64-bit integer for name, NOT clamped.
 
int64_t dt_conf_get_int64 (const char *name)
 64-bit integer for name, clamped to its declared bounds.
 
float dt_conf_get_float_fast (const char *name)
 Stored float for name, NOT clamped.
 
float dt_conf_get_float (const char *name)
 Float for name, clamped to its declared bounds.
 
int dt_conf_get_and_sanitize_int (const char *name, int min, int max)
 
int64_t dt_conf_get_and_sanitize_int64 (const char *name, int64_t min, int64_t max)
 
float dt_conf_get_and_sanitize_float (const char *name, float min, float max)
 
int dt_conf_get_bool (const char *name)
 
gchar * dt_conf_get_string (const char *name)
 Read the stored string for name as a private copy.
 
const char * dt_conf_get_string_const (const char *name)
 Borrow the stored string for name without copying it.
 
gboolean dt_conf_key_not_empty (const char *name)
 
gboolean dt_conf_get_folder_to_file_chooser (const char *name, GtkFileChooser *chooser)
 
gboolean dt_conf_is_equal (const char *name, const char *value)
 
static char * _sanitize_confgen (const char *name, const char *value)
 
void dt_conf_init (dt_conf_t *cf, const char *filename, GSList *override_entries)
 Populate cf from filename and from the generated defaults.
 
int dt_conf_key_exists (const char *key)
 Does key have a value?
 
static void _conf_add (char *key, char *val, dt_conf_dreggn_t *d)
 
GSList * dt_conf_all_string_entries (const char *dir)
 Every key under dir, as a list of copies.
 
void dt_conf_string_entry_free (gpointer data)
 Free one dt_conf_string_entry_t. Shaped as a GDestroyNotify so it can be handed to g_slist_free_full().
 
gboolean dt_confgen_exists (const char *name)
 
dt_confgen_type_t dt_confgen_type (const char *name)
 
gboolean dt_confgen_value_exists (const char *name, dt_confgen_value_kind_t kind)
 
const char * dt_confgen_get (const char *name, dt_confgen_value_kind_t kind)
 One declared attribute of name from the generated XML, as text.
 
const char * dt_confgen_get_label (const char *name)
 Translated short description of name, borrowed and valid for the process lifetime. NULL when name is not declared.
 
const char * dt_confgen_get_tooltip (const char *name)
 Translated long description of name, borrowed and valid for the process lifetime. NULL when name is not declared.
 
int dt_confgen_get_int (const char *name, dt_confgen_value_kind_t kind)
 
int64_t dt_confgen_get_int64 (const char *name, dt_confgen_value_kind_t kind)
 
gboolean dt_confgen_get_bool (const char *name, dt_confgen_value_kind_t kind)
 
float dt_confgen_get_float (const char *name, dt_confgen_value_kind_t kind)
 
gboolean dt_conf_is_default (const char *name)
 Is name still at the value declared in the XML? FALSE for an undeclared key.
 
gchar * dt_conf_expand_default_dir (const char *dir)
 Expand the placeholders in a default directory string.
 
static void dt_conf_print (const gchar *key, const gchar *val, FILE *f)
 
void dt_conf_save (dt_conf_t *cf)
 Write cf back to its file. Overridden keys keep their stored value.
 
void dt_conf_cleanup (dt_conf_t *cf)
 Free everything cf owns. No dt_conf_*() call is valid afterwards.
 

Variables

static dt_atomic_uint64 _conf_generation = 1
 Store str for name unless the command line pinned that key.
 

Macro Definition Documentation

◆ CONFIG_DIR

#define CONFIG_DIR   "$(config)"

◆ HOME_DIR

#define HOME_DIR   "$(home)"

◆ LINE_SIZE

#define LINE_SIZE   1023

Typedef Documentation

◆ dt_conf_dreggn_t

Function Documentation

◆ _conf_add()

static void _conf_add ( char *  key,
char *  val,
dt_conf_dreggn_t *  d 
)
static

Definition at line 655 of file common/conf.c.

References d, dt_conf_string_entry_t::key, key, and L.

Referenced by dt_conf_all_string_entries().

◆ _dt_conf_get_var_locked()

static char * _dt_conf_get_var_locked ( const char *  name)
inlinestatic

same as dt_conf_get_var(), but the caller must already hold darktable.conf->mutex. The returned pointer is only valid for as long as that lock stays held: a concurrent dt_conf_set_*() on the same key can free it (g_hash_table_insert() destroys the old value it replaces) the instant the lock is released. Callers that need the value to survive past the lock (e.g. to compare or duplicate it) must do so before unlocking – see dt_conf_get_string() below for the pattern.

Todo:
: why insert garbage?

Definition at line 88 of file common/conf.c.

References darktable_t::conf, darktable, dt_confgen_get(), DT_DEFAULT, IS_NULL_PTR, L, name, dt_conf_t::override_entries, and dt_conf_t::table.

Referenced by dt_conf_get_string(), and dt_conf_get_var().

◆ _free_confgen_value()

◆ _sanitize_confgen()

◆ dt_conf_all_string_entries()

GSList * dt_conf_all_string_entries ( const char *  dir)

Every key under dir, as a list of copies.

get all strings in

Definition at line 667 of file common/conf.c.

References _conf_add(), darktable_t::conf, d, darktable, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), L, dt_conf_t::mutex, dt_conf_dreggn_t::result, and dt_conf_t::table.

Referenced by gui_init().

◆ dt_conf_cleanup()

void dt_conf_cleanup ( dt_conf_t *  cf)

Free everything cf owns. No dt_conf_*() call is valid afterwards.

Definition at line 974 of file common/conf.c.

References darktable_t::conf, darktable, dt_conf_save(), dt_pthread_mutex_destroy(), L, and dt_conf_t::mutex.

Referenced by _teardown(), _teardown(), cache_teardown(), and dt_cleanup().

◆ dt_conf_expand_default_dir()

gchar * dt_conf_expand_default_dir ( const char *  dir)

Expand the placeholders in a default directory string.

Returns
a newly-allocated string. The caller owns it and must g_free() it.

Definition at line 922 of file common/conf.c.

References CONFIG_DIR, dt_free, dt_loc_get_home_dir(), dt_loc_get_user_config_dir(), DT_PATH_MAX, dt_util_normalize_path(), HOME_DIR, and L.

◆ dt_conf_generation()

uint64_t dt_conf_generation ( void  )

A counter that advances whenever a conf value actually changes.

For code on a hot path that would otherwise read conf per call: keep what you derived alongside the generation you derived it at, and re-derive only when the two differ. Every dt_conf_get_* takes the application-wide conf mutex – the same one the GUI thread uses – and dt_conf_get_float additionally runs dt_calculator_solve() over the stored string, so on a pipeline thread this is contention, not arithmetic.

It never goes backwards and starts at 1, so 0 is usable as "nothing cached yet".

NOTE this says the CONFIGURATION changed, not that your derived value did. It is a cache key, never a substitute for folding state into a pipeline hash: a module whose pixels depend on a conf value still owes that value to its cache key (see iop/gamma.c and runtime_data_hash() in iop/iop_api.h), or the pipe serves pixels the key does not describe.

Definition at line 160 of file common/conf.c.

References _conf_generation, and dt_atomic_get_uint64().

Referenced by _the_generation_advances_on_a_change_and_not_otherwise(), and _userpref_cached().

◆ dt_conf_get_and_sanitize_float()

float dt_conf_get_and_sanitize_float ( const char *  name,
float  min,
float  max 
)

◆ dt_conf_get_and_sanitize_int()

int dt_conf_get_and_sanitize_int ( const char *  name,
int  min,
int  max 
)

◆ dt_conf_get_and_sanitize_int64()

int64_t dt_conf_get_and_sanitize_int64 ( const char *  name,
int64_t  min,
int64_t  max 
)

◆ dt_conf_get_bool()

int dt_conf_get_bool ( const char *  name)

Definition at line 442 of file common/conf.c.

References dt_conf_get_var(), L, and name.

Referenced by __attribute__(), _add_sample(), _ask_before_delete_style(), _choose_gpx_callback(), _collect_sorted_tree_names(), _colorspaces_build(), _compute_hud_brush_state(), _configure_tab(), _confirm_pending_import(), _datetime_key_pressed(), _delete_tagids(), _display_offset(), _dt_collection_changed_callback(), _export_button_clicked(), _file_activated(), _fill_input_brush_settings(), _film_import1(), _folder_survey_job_run(), _gui_presets_popup_menu_show_internal(), _history_copy_and_paste_on_image_merge(), _history_paste_apply(), _history_paste_parts_apply(), _history_style_apply(), _image_info_changed(), _init_expansion(), _init_widgets(), _menuitem_delete_preset(), _menuitem_update_preset(), _metadata_view_update_values(), _mipmap_settings_from_conf(), _new_datetime(), _panel_is_visible(), _populate_tree(), _process_file_list(), _refresh_brush_settings_cache(), _refresh_global_picker(), _remove_sample_cb(), _rule_get_recursive(), _seal_opencl_cache_policy(), _selection_changed_callback(), _set_sample_box_area(), _set_sample_point(), _set_test_path(), _setup_selected_images_list(), _show_milliseconds(), _studio_import_update_preview(), _styles_apply_callback(), _styles_ask_callback(), _styles_ask_checked_callback(), _styles_copy_iop_order_callback(), _styles_copy_iop_order_checked_callback(), _timezone_save(), _toggle_suggestion_button_callback(), _toggle_tree_button_callback(), _update_layout(), _variables_get_latitude(), _variables_get_longitude(), _view_map_button_press_callback(), _view_map_collection_changed(), _view_map_draw_main_location(), _view_map_draw_other_locations(), _view_map_show_osd(), _widget_stored_bool(), ask_user_confirmation(), collapse_grouped_callback(), collapse_grouped_checked_callback(), commit_params(), commit_params(), copy_iop_order_callback(), copy_iop_order_checked_callback(), delete_file_from_disk(), delete_history_callback(), dt_collection_get_browsed_folder(), dt_collection_get_property_values(), dt_collection_reset(), dt_collection_serialize(), dt_collection_update_query(), dt_conf_is_default(), dt_control_copy_images(), dt_control_delete_image(), dt_control_delete_images(), dt_control_delete_images_job_run(), dt_control_move_images(), dt_control_remove_images(), dt_dev_init(), dt_drawlayer_conf_ensure_defaults(), dt_drawlayer_conf_load_color_history(), dt_exif_decode_xmp_data(), dt_film_remove_empty(), dt_folder_survey_can_start(), dt_folder_survey_destination_preview(), dt_folder_survey_start(), dt_gui_gtk_init(), dt_gui_load_theme(), dt_gui_merge_options_dialog(), dt_gui_preferences_bool(), dt_gui_preferences_bool_update(), dt_guides_draw(), dt_guides_update_button_state(), dt_init(), dt_iop_commit_params(), dt_lib_gui_get_expanded(), dt_lib_is_visible(), dt_lib_presets_popup_menu_show(), dt_mask_scroll_increases(), dt_masks_gui_confirm_permanent_delete(), dt_module_load_modules(), dt_opencl_device_init(), dt_opencl_init(), dt_opencl_update_settings(), dt_privacy_ask_consent(), dt_styles_apply_to_image_merge(), dt_tag_get_list(), dt_thumbtable_new(), dt_ui_restore_panels(), dt_updates_init(), dt_view_manager_switch_by_view(), export_clicked(), get_params(), get_params(), group_borders_callback(), group_borders_checked_callback(), gui_cleanup(), gui_init(), gui_init(), gui_init(), gui_init(), gui_init(), gui_update(), gui_update(), import_clicked(), init(), init_tab_general(), legacy_params(), main(), menuitem_delete_preset(), menuitem_update_preset(), paste_all_callback(), paste_ask_callback(), paste_ask_checked_callback(), paste_parts_callback(), set_format_by_name(), update_preview_cb(), and use_sys_font_callback().

◆ dt_conf_get_float()

◆ dt_conf_get_float_fast()

float dt_conf_get_float_fast ( const char *  name)

◆ dt_conf_get_folder_to_file_chooser()

◆ dt_conf_get_int()

int dt_conf_get_int ( const char *  name)

Integer for name, clamped to the bounds declared in the XML.

Definition at line 319 of file common/conf.c.

References dt_conf_get_int_fast(), dt_confgen_get_int(), DT_MAX, DT_MIN, L, max, min, and name.

Referenced by __attribute__(), _active_channel_from_gui(), _active_ring_from_gui(), _build_display_popover(), _collection_folder_ui_inactive(), _colorspaces_build(), _columns_in_action(), _columns_out_action(), _configure_tab(), _database_settings_from_conf(), _dimensions_type(), _dt_collection_changed_callback(), _dt_opencl_get_conf_int(), _ellipse_get_creation_values(), _ensure_print_size_conf(), _export_button_clicked(), _folder_survey_job_run(), _folder_survey_reschedule(), _get_current_tab(), _get_recent_tags_list_length(), _gpu_runtime_crash_streak(), _grid_configure_dims(), _guides_gui_grid(), _history_paste_apply(), _history_paste_parts_apply(), _init_widgets(), _jpg_checked(), _jpg_combobox_changed(), _menuitem_preferences(), _mipmap_settings_from_conf(), _name_editing_done(), _panel_is_visible(), _populate_collect_combo(), _print_button_clicked(), _print_dpi(), _resolve_export_size(), _rule_get_item(), _rule_get_mode(), _rules_count(), _set_params(), _settings_flip_update(), _shape_button_clicked(), _shape_manager_popup_restore_geometry(), _styles_history_append_checked_callback(), _styles_history_prepend_checked_callback(), _styles_history_replace_checked_callback(), _thumb_draw_image(), _thumbs_update_overlays_mode(), _thumbtable_scroll(), _ui_init_panel_left(), _ui_init_panel_size(), _update_layout(), _update_recentcollections(), _validate_dimensions(), _view_map_changed_callback_delayed(), _view_map_display_selected(), _view_map_location_changed(), _widget_stored_int(), _xmp_append_metadata(), always_hide_overlays_checked_callback(), always_show_overlays_checked_callback(), commit_params(), commit_params(), dt_cleanup(), dt_collection_get_browsed_folder(), dt_collection_get_property_values(), dt_collection_load_filmroll(), dt_collection_name(), dt_collection_reset(), dt_collection_serialize(), dt_collection_update_query(), dt_conf_is_default(), dt_dev_get_background_color(), dt_dev_init(), dt_dev_toolbox_apply_iso_12646_size(), dt_drawlayer_conf_brush_mode(), dt_drawlayer_conf_brush_shape(), dt_drawlayer_conf_mapping_profile(), dt_drawlayer_conf_pick_source(), dt_exif_read_blob(), dt_gui_merge_options_dialog(), dt_gui_preferences_int(), dt_gui_preferences_int_update(), dt_gui_preferences_show(), dt_guides_draw(), dt_guides_draw_grid(), dt_guides_popover(), dt_guides_set_overlay_colors(), dt_guides_update_popover_values(), dt_history_style_on_image(), dt_history_style_on_list(), dt_image_film_roll_name(), dt_init(), dt_iop_autoset_module_is_enabled(), dt_iop_gui_init_blending_body(), dt_lib_queue_postponed_update(), dt_metadata_clear(), dt_metadata_set_import(), dt_opencl_apply_scheduling_profile(), dt_opencl_detected_device_enabled(), dt_opencl_detected_device_headroom(), dt_opencl_detected_device_pinned_memory(), dt_opencl_init(), dt_opencl_read_device_config(), dt_opencl_reserve_device_for_pipe(), dt_pthread_create(), dt_tag_get_suggestions(), dt_ui_panel_get_size(), dt_ui_panel_show(), dt_ui_restore_panels(), dt_ui_toggle_panels_visibility(), dt_worker_threads(), enter(), get_params(), get_params(), get_params(), gui_init(), gui_init(), gui_init(), gui_init(), gui_init(), gui_init(), gui_init(), gui_reset(), gui_reset(), gui_update(), gui_update(), history_append_checked_callback(), history_prepend_checked_callback(), history_replace_checked_callback(), hover_overlays_checked_callback(), init(), modify_roi_in(), reload_defaults(), reload_defaults(), set_storage_by_name(), write_image(), write_image(), and xtrans_fdc_interpolate().

◆ dt_conf_get_int64()

int64_t dt_conf_get_int64 ( const char *  name)

64-bit integer for name, clamped to its declared bounds.

Definition at line 364 of file common/conf.c.

References dt_conf_get_int64_fast(), dt_confgen_get_int64(), DT_MAX, DT_MIN, L, max, min, and name.

Referenced by dt_conf_is_default(), dt_configure_runtime_performance(), dt_opencl_read_device_config(), and dt_updates_init().

◆ dt_conf_get_int64_fast()

int64_t dt_conf_get_int64_fast ( const char *  name)

Stored 64-bit integer for name, NOT clamped.

Definition at line 328 of file common/conf.c.

References dt_calculator_solve(), dt_conf_get_var(), dt_conf_set_if_not_overridden(), dt_confgen_get(), DT_DEFAULT, dt_free, IS_NULL_PTR, L, and name.

Referenced by dt_conf_get_and_sanitize_int64(), and dt_conf_get_int64().

◆ dt_conf_get_int_fast()

int dt_conf_get_int_fast ( const char *  name)

◆ dt_conf_get_string()

gchar * dt_conf_get_string ( const char *  name)

Read the stored string for name as a private copy.

The copy is taken while the lock is held, so it cannot race a concurrent dt_conf_set_*() on the same key.

Returns
a newly-allocated string. The caller owns it and must g_free() it. Never NULL: an unknown key is created on demand and yields the XML default, or an empty value.

Definition at line 449 of file common/conf.c.

References _dt_conf_get_var_locked(), darktable_t::conf, darktable, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), L, dt_conf_t::mutex, and name.

Referenced by _accels_recent_get(), _apply_filmroll_gpx(), _apply_gpx(), _choose_gpx_callback(), _conf_get_guide(), _configure_slider_blocks(), _database_settings_from_conf(), _dnd_folder_import_job_run(), _export_button_clicked(), _folder_survey_job_run(), _folder_survey_scan(), _folder_survey_styles_for_import(), _guides_add_guide(), _load_selection(), _new_printer_callback(), _print_button_clicked(), _process_file_list(), _rule_get_string(), _save_clut_callback(), _scale_optim(), _set_paper_size(), _set_test_path(), _studio_import_update_state(), _studio_style_load_pool(), _style_callback(), _thumbtable_dnd_import(), _update_recentcollections(), button_clicked(), calculate_clut(), dt_bauhaus_combobox_from_conf(), dt_collection_get_browsed_folder(), dt_collection_reset(), dt_collection_update_query(), dt_dev_roi_request_publish(), dt_exif_xmp_encode(), dt_folder_survey_absorb_new_files(), dt_folder_survey_count_new_files(), dt_folder_survey_destination_preview(), dt_folder_survey_init(), dt_folder_survey_propose_resume(), dt_folder_survey_start(), dt_gui_preferences_enum(), dt_gui_preferences_enum_update(), dt_gui_presets_init(), dt_guides_update_popover_values(), dt_image_xmp_mode_refresh_from_conf(), dt_imageio_is_handled_by_libraw(), dt_init(), dt_install_id(), dt_l10n_init(), dt_lib_export_metadata_get_conf(), dt_opencl_update_priorities(), dt_view_audio_start(), dt_view_image_info_update(), get_params(), gui_init(), gui_init(), gui_init(), gui_reset(), gui_update(), gui_update(), and init_tab_general().

◆ dt_conf_get_string_const()

const char * dt_conf_get_string_const ( const char *  name)

Borrow the stored string for name without copying it.

Returns
a pointer into the conf table. Do not free it. Valid for the lifetime of the process, and never NULL.
Warning
It can go STALE. It is a snapshot: a later dt_conf_set_*() on the same key installs a new string and leaves this one behind, so a caller holding the pointer keeps reading the value as it was. Re-read the key when currency matters, or take a private copy with dt_conf_get_string() when the value must be carried somewhere.
Note
This used to be a use-after-free rather than a staleness question: the value was freed the moment another thread replaced it, while the reader still held the pointer – the mechanism behind a "write_sidecar_files silently flips to FALSE" report. dt_conf_set_if_not_overridden() now retires displaced values instead of freeing them, which fixes every caller at once rather than asking 98 call sites to be audited individually.

Definition at line 464 of file common/conf.c.

References dt_conf_get_var(), and name.

Referenced by _borrowed_value_survives_being_replaced(), _colorspaces_build(), _configure_tab(), _dt_check_basedir(), _every_displaced_value_stays_readable(), _export_button_clicked(), _export_button_clicked(), _get_brush_smoothing(), _get_max_output_dimension(), _get_pressure_sensitivity(), _import_button_clicked(), _lib_location_search(), _resolve_by_name(), _resolve_export_size(), _rewriting_the_same_value_retires_nothing(), _save_last_tag_used(), _set_params(), _set_printer(), _size_recent_tags_list(), _the_generation_advances_on_a_change_and_not_otherwise(), _thumbnail_change_accel(), _typed_setters_retire_too(), _update(), _update_formats_combobox(), _update_recentcollections(), _updates_worker(), dt_collection_get_property_values(), dt_collection_serialize(), dt_colorspaces_set_display_profile(), dt_conf_get_folder_to_file_chooser(), dt_conf_key_not_empty(), dt_folder_survey_can_start(), dt_gui_gtk_init(), dt_gui_preferences_string(), dt_gui_preferences_string_update(), dt_imageio_get_format(), dt_imageio_get_storage(), dt_lib_export_metadata_get_conf_flags(), dt_masks_scroll_mapping_get(), dt_opencl_device_init(), dt_opencl_init(), dt_tag_get_suggestions(), enter(), get_params(), get_params(), gui_init(), gui_init(), gui_init(), gui_init(), gui_init(), gui_init(), init(), init_collection_line(), reload_ui_last_theme(), set_storage_by_name(), and update_collection_callback().

◆ dt_conf_get_var()

static char * dt_conf_get_var ( const char *  name)
inlinestatic

◆ dt_conf_init()

void dt_conf_init ( dt_conf_t *  cf,
const char *  filename,
GSList *  override_entries 
)

Populate cf from filename and from the generated defaults.

Must run before ANY other dt_conf_*() call: the rest of this API reaches darktable.conf unconditionally.

Parameters
cfstorage to initialise, normally darktable.conf.
filenameanselrc to read; created from defaults when absent.
override_entriescommand-line overrides, as dt_conf_string_entry_t. They win over stored values on read and are not written back on save.

Definition at line 563 of file common/conf.c.

References _free_confgen_value(), _sanitize_confgen(), darktable_t::conf, darktable, dt_confgen_value_t::def, dt_free_gpointer(), dt_pthread_mutex_init(), f, dt_conf_t::filename, IS_NULL_PTR, dt_conf_string_entry_t::key, key, L, LINE_SIZE, dt_conf_t::mutex, name, dt_conf_t::override_entries, p, STR, dt_conf_t::table, dt_conf_string_entry_t::value, value, and dt_conf_t::x_confgen.

Referenced by _setup(), _setup(), cache_setup(), and dt_init().

◆ dt_conf_is_default()

gboolean dt_conf_is_default ( const char *  name)

◆ dt_conf_is_equal()

gboolean dt_conf_is_equal ( const char *  name,
const char *  value 
)

Definition at line 488 of file common/conf.c.

References dt_conf_get_var(), L, name, and value.

Referenced by commit_params(), and reload_defaults().

◆ dt_conf_key_exists()

◆ dt_conf_key_not_empty()

◆ dt_conf_print()

static void dt_conf_print ( const gchar *  key,
const gchar *  val,
FILE *  f 
)
static

Definition at line 949 of file common/conf.c.

References f, key, and L.

Referenced by dt_conf_save().

◆ dt_conf_save()

void dt_conf_save ( dt_conf_t *  cf)

Write cf back to its file. Overridden keys keep their stored value.

Definition at line 954 of file common/conf.c.

References dt_conf_print(), f, IS_NULL_PTR, key, and L.

Referenced by dt_conf_cleanup(), and dt_opencl_device_init().

◆ dt_conf_set_bool()

void dt_conf_set_bool ( const char *  name,
int  val 
)

Definition at line 236 of file common/conf.c.

References dt_conf_set_if_not_overridden(), dt_free, L, and name.

Referenced by _attached_view_combo_changed(), _auto_set_illuminant(), _cache_disable_callback(), _callback_bool(), _confirm_pending_import(), _copy_toggled_callback(), _display_samples_changed(), _dttags_check_toggled(), _gui_preferences_bool_callback(), _gui_set_single_expanded(), _lock_callback(), _no_uncategorized_toggled(), _opencl_disable_callback(), _printer_bpc_callback(), _restrict_histogram_changed(), _rule_set_recursive(), _seal_opencl_cache_policy(), _show_all_button_clicked(), _sort_combo_changed(), _sort_dir_toggled(), _spot_settings_changed_callback(), _store_color_history(), _studio_import_copy_callback(), _studio_import_delete_callback(), _styles_ask_callback(), _styles_copy_iop_order_callback(), _toggle_suggestion_button_callback(), _toggle_tree_button_callback(), _widget_store_bool(), apply_style_to_image(), collapse_grouped_callback(), copy_iop_order_callback(), delete_history_callback(), display_mask_black_and_white_callback(), dt_collection_deserialize(), dt_collection_update(), dt_drawlayer_conf_ensure_defaults(), dt_drawlayer_conf_sync_params_from_gui(), dt_gui_gtk_write_config(), dt_gui_load_theme(), dt_gui_merge_options_dialog(), dt_guides_button_toggled(), dt_iop_commit_params(), dt_lib_gui_set_expanded(), dt_lib_set_visible(), dt_masks_gui_confirm_permanent_delete(), dt_module_load_modules(), dt_opencl_disable(), dt_opencl_read_device_config(), dt_opencl_set_detected_device_enabled(), dt_privacy_ask_consent(), dt_ui_panel_show(), duplicate_callback(), group_borders_callback(), gui_init(), icc_toggle_callback(), paste_ask_callback(), rotate_toggle_callback(), set_format_by_name(), set_params(), tiling_changed(), use_sys_font_callback(), and usercss_callback().

◆ dt_conf_set_float()

◆ dt_conf_set_folder_from_file_chooser()

◆ dt_conf_set_if_not_overridden()

◆ dt_conf_set_int()

void dt_conf_set_int ( const char *  name,
int  val 
)

Definition at line 208 of file common/conf.c.

References dt_conf_set_if_not_overridden(), dt_free, L, and name.

Referenced by _blendop_blending_notebook_switch(), _channel_tabs_switch_callback(), _channelmixerrgb_mixer_mode_callback(), _channelmixerrgb_reject_mixer_mode(), _colorspaces_destroy(), _columns_in_action(), _columns_out_action(), _confidence_changed(), _control_import_job_run(), _darkroom_change_rendering_size(), _dimensions_type_changed(), _display_borders_callback(), _display_brightness_callback(), _dt_collection_changed_callback(), _ellipse_events_button_released(), _event_aspect_presets_changed(), _folder_levels_changed(), _gpu_runtime_set_crash_streak(), _gradient_events_button_released(), _grid_horizontal_changed(), _grid_subdiv_changed(), _grid_vertical_changed(), _gui_preferences_int_callback(), _height_changed(), _intent_callback(), _intent_changed(), _jpg_combobox_changed(), _lib_collect_gui_update(), _lib_lighttable_columns_slider_changed(), _menuitem_preferences(), _mixer_mode_callback(), _mouse_scroll(), _on_tab_switch(), _panel_handle_resize(), _print_dpi_changed(), _printer_intent_callback(), _printer_profile_changed(), _profile_changed(), _profile_changed(), _recent_tags_changed(), _resize_dialog(), _resize_dialog(), _ring_tabs_switch_callback(), _rule_set_item(), _rule_set_mode(), _rules_set_count(), _scope_resize_handle_resize(), _set_columns(), _set_delay(), _set_dimensions(), _set_scope(), _set_stage(), _settings_colors_changed(), _settings_flip_changed(), _shape_button_clicked(), _shape_manager_popup_save_geometry(), _studio_import_conflict_callback(), _studio_import_interval_callback(), _styles_history_append_callback(), _styles_history_prepend_callback(), _styles_history_replace_callback(), _switch_page(), _the_generation_advances_on_a_change_and_not_otherwise(), _thumbtable_scroll(), _typed_setters_retire_too(), _update_point_gui(), _update_recentcollections(), _view_map_changed_callback_delayed(), _view_map_location_changed(), _widget_store_int(), _width_changed(), area_button_press(), aspect_presets_changed(), bit_depth_changed(), bit_depth_changed(), bpp_combobox_changed(), bpp_combobox_changed(), bpp_toggle_callback(), color_mode_changed(), compress_combobox_changed(), compress_level_changed(), compression_changed(), compression_combobox_changed(), compression_level_changed(), compression_toggle_callback(), compression_type_changed(), cropmode_callback(), display_mask_checker_size_callback(), dt_cleanup(), dt_collection_deserialize(), dt_collection_load_filmroll(), dt_collection_update(), dt_conf_get_and_sanitize_int(), dt_dev_cleanup(), dt_drawlayer_conf_ensure_defaults(), dt_drawlayer_conf_sync_params_from_gui(), dt_film_set_query(), dt_gui_gtk_write_config(), dt_gui_merge_options_dialog(), dt_iop_autoset_module_set_enabled(), dt_metadata_init(), dt_opencl_set_detected_device_enabled(), dt_opencl_set_detected_device_headroom(), dt_opencl_set_detected_device_pinned_memory(), dt_opencl_write_device_config(), dt_thumbtable_set_overlays_mode(), dt_ui_panel_show(), dt_ui_toggle_panels_visibility(), format_changed(), get_params(), gui_changed(), gui_cleanup(), gui_cleanup(), gui_init(), gui_init(), gui_reset(), gui_reset(), hint_combobox_changed(), history_append_callback(), history_prepend_callback(), history_replace_callback(), mode_toggle_callback(), onsave_action_toggle_callback(), optimize_changed_callback(), orientation_toggle_callback(), pages_toggle_callback(), preset_changed(), quality_changed(), quality_changed(), quality_changed(), quality_changed(), rt_select_algorithm_callback(), set_params(), and shortfile_combobox_changed().

◆ dt_conf_set_int64()

void dt_conf_set_int64 ( const char *  name,
int64_t  val 
)

Definition at line 217 of file common/conf.c.

References dt_conf_set_if_not_overridden(), dt_free, L, and name.

Referenced by dt_conf_get_and_sanitize_int64(), and dt_updates_init().

◆ dt_conf_set_string()

void dt_conf_set_string ( const char *  name,
const char *  val 
)

Definition at line 245 of file common/conf.c.

References dt_conf_set_if_not_overridden(), dt_free, L, and name.

Referenced by _accels_recent_set(), _base_dir_changed(), _borrowed_value_survives_being_replaced(), _color_mode_changed(), _colorspaces_destroy(), _combobox_conf_value_changed(), _conf_get_guide(), _darkroom_change_mask_rasterization(), _database_renamed(), _dt_check_basedir(), _every_displaced_value_stays_readable(), _export_button_clicked(), _filename_changed(), _gui_preferences_enum_callback(), _gui_preferences_string_callback(), _import_button_clicked(), _insert_default_modules(), _jobcode_changed(), _media_changed(), _paper_changed(), _printer_profile_changed(), _profile_changed(), _profile_changed(), _project_dir_changed(), _rewriting_the_same_value_retires_nothing(), _rule_get_string(), _rule_set_string(), _save_last_tag_used(), _save_preferences(), _save_selection(), _scale_changed(), _scale_optim(), _set_paper_size(), _set_params(), _set_printer(), _set_stage(), _settings_guides_changed(), _size_recent_tags_list(), _sort_by_changed(), _statistic_changed(), _studio_import_base_folder_callback(), _studio_import_datetime_callback(), _studio_import_file_pattern_callback(), _studio_import_jobcode_callback(), _studio_import_source_folder_callback(), _studio_import_subfolder_callback(), _studio_style_save(), _style_callback(), _style_changed(), _the_generation_advances_on_a_change_and_not_otherwise(), _thumbnail_change_accel(), _timezone_save(), _unit_changed(), _update_directory(), _update_recentcollections(), _view_map_set_map_source(), border_changed_callback(), checker_changed_callback(), checker_color_changed_callback(), dt_collection_deserialize(), dt_collection_load_filmroll(), dt_collection_update(), dt_dev_init_default_history(), dt_film_set_query(), dt_folder_survey_init(), dt_folder_survey_start(), dt_gui_load_theme(), dt_gui_presets_init(), dt_guides_update_popover_values(), dt_image_xmp_mode_refresh_from_conf(), dt_install_id(), dt_lib_export_metadata_set_conf(), dt_lib_presets_apply(), dt_masks_scroll_mapping_set(), dt_opencl_device_init(), entry_changed_callback(), entry_changed_callback(), fontsel_callback(), gui_init(), gui_reset(), init(), language_callback(), leave(), set_format_by_name(), set_params(), set_params(), set_storage_by_name(), set_visible_widgets(), text_callback(), title_changed_callback(), and title_changed_callback().

◆ dt_conf_string_entry_free()

void dt_conf_string_entry_free ( gpointer  data)

Free one dt_conf_string_entry_t. Shaped as a GDestroyNotify so it can be handed to g_slist_free_full().

Definition at line 678 of file common/conf.c.

References dt_free, and L.

Referenced by gui_init().

◆ dt_confgen_exists()

gboolean dt_confgen_exists ( const char *  name)

Definition at line 688 of file common/conf.c.

References darktable_t::conf, darktable, L, name, and dt_conf_t::x_confgen.

Referenced by dt_conf_is_default().

◆ dt_confgen_get()

const char * dt_confgen_get ( const char *  name,
dt_confgen_value_kind_t  kind 
)

One declared attribute of name from the generated XML, as text.

Parameters
kindwhich attribute: default, min, max, or the enum's value list.
Returns
a pointer into the confgen table, or NULL when name or kind is not declared. Do NOT free it. Unlike dt_conf_get_string_const(), this one is safe to hold: the confgen table is built once at init and never mutated, which is also why these readers take no lock.

Definition at line 723 of file common/conf.c.

References darktable_t::conf, darktable, dt_confgen_value_t::def, DT_DEFAULT, DT_MAX, DT_MIN, DT_VALUES, dt_confgen_value_t::enum_values, IS_NULL_PTR, kind, L, dt_confgen_value_t::max, dt_confgen_value_t::min, name, and dt_conf_t::x_confgen.

Referenced by _dt_conf_get_var_locked(), _sanitize_confgen(), dt_bauhaus_combobox_from_conf(), dt_conf_get_float_fast(), dt_conf_get_int64_fast(), dt_conf_get_int_fast(), dt_conf_is_default(), dt_confgen_get_bool(), dt_confgen_get_float(), dt_confgen_get_int(), dt_confgen_get_int64(), dt_gui_preferences_enum(), dt_gui_preferences_enum_reset(), dt_gui_preferences_string_reset(), gui_reset(), and gui_reset().

◆ dt_confgen_get_bool()

gboolean dt_confgen_get_bool ( const char *  name,
dt_confgen_value_kind_t  kind 
)

Definition at line 845 of file common/conf.c.

References dt_confgen_get(), kind, L, and name.

Referenced by dt_conf_is_default(), dt_gui_preferences_bool_reset(), gui_reset(), and gui_reset().

◆ dt_confgen_get_float()

◆ dt_confgen_get_int()

◆ dt_confgen_get_int64()

int64_t dt_confgen_get_int64 ( const char *  name,
dt_confgen_value_kind_t  kind 
)

◆ dt_confgen_get_label()

const char * dt_confgen_get_label ( const char *  name)

Translated short description of name, borrowed and valid for the process lifetime. NULL when name is not declared.

Definition at line 745 of file common/conf.c.

References darktable_t::conf, darktable, IS_NULL_PTR, L, name, dt_confgen_value_t::shortdesc, and dt_conf_t::x_confgen.

Referenced by dt_bauhaus_combobox_from_conf(), dt_gui_preferences_bool(), dt_gui_preferences_enum(), dt_gui_preferences_int(), dt_gui_preferences_string(), and gui_init().

◆ dt_confgen_get_tooltip()

const char * dt_confgen_get_tooltip ( const char *  name)

Translated long description of name, borrowed and valid for the process lifetime. NULL when name is not declared.

Definition at line 757 of file common/conf.c.

References darktable_t::conf, darktable, IS_NULL_PTR, L, dt_confgen_value_t::longdesc, name, and dt_conf_t::x_confgen.

Referenced by dt_bauhaus_combobox_from_conf(), dt_gui_preferences_bool(), dt_gui_preferences_enum(), dt_gui_preferences_int(), dt_gui_preferences_string(), and gui_init().

◆ dt_confgen_type()

◆ dt_confgen_value_exists()

Variable Documentation

◆ _conf_generation

dt_atomic_uint64 _conf_generation = 1
static

Store str for name unless the command line pinned that key.

This is the ONLY writer that can replace an existing value while the application is running – the two inserts in _dt_conf_get_var_locked() only fire when the key is absent, and the two in dt_conf_init() run before any reader exists.

That makes it the one place where dt_conf_get_string_const()'s borrowed pointer could be pulled out from under a reader. It used to be: g_hash_table_insert() destroys the value it replaces, and the table's value_destroy_func is a free. A reader that had taken the pointer and released the lock – which dt_conf_get_var() does before returning – was then reading freed memory. Rather than free the old value here, we RETIRE it: it is moved to darktable.conf->retired_values and released only at dt_conf_cleanup(). A stale read is possible where a use-after-free was; the pointer itself stays valid for the process lifetime.

Retiring only happens when the value actually CHANGES. Writing a key back with the value it already holds – which GUI state saving does constantly – stores nothing and retires nothing, so the retired list grows with real edits and not with idle churn.

Parameters
namekey to write.
strthe value. Ownership TRANSFERS to this function only when it returns 0.
Returns
non-zero when the value was not stored – either the command line pinned this key, or it already held exactly this value. **The caller still owns str and must free it.**

Definition at line 158 of file common/conf.c.

Referenced by dt_conf_generation(), and dt_conf_set_if_not_overridden().