Change behaviour of WmudConfiguration.update_from_file()

filename can be NULL now, in which case it will use the already set config file.
This commit is contained in:
Gergely Polonkai 2016-07-06 10:17:21 +00:00
parent 6eb1e09cc3
commit ee4050c5f6
2 changed files with 7 additions and 8 deletions

View File

@ -200,7 +200,6 @@ main(int argc, char **argv)
GError *err = NULL; GError *err = NULL;
GSList *game_menu = NULL; GSList *game_menu = NULL;
WmudConfiguration *current_config = NULL; WmudConfiguration *current_config = NULL;
gchar *filename = NULL;
g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_MASK, wmud_logger, NULL); g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_MASK, wmud_logger, NULL);
@ -214,12 +213,8 @@ main(int argc, char **argv)
/* TODO: Create signal handlers! */ /* TODO: Create signal handlers! */
if ((filename = wmud_configuration_get_filename(current_config)) == NULL) {
filename = WMUD_CONFDIR "/wmud.conf";
}
// Process configuration file // Process configuration file
wmud_configuration_update_from_file(current_config, filename, NULL); wmud_configuration_update_from_file(current_config, NULL, NULL);
if (!wmud_config_init(&active_config, &err)) { if (!wmud_config_init(&active_config, &err)) {
if (err) { if (err) {

View File

@ -98,8 +98,12 @@ wmud_configuration_update_from_file(WmudConfiguration *configuration,
WmudConfigurationPrivate *priv = wmud_configuration_get_instance_private( WmudConfigurationPrivate *priv = wmud_configuration_get_instance_private(
configuration); configuration);
// Save the file name for possible later use if (filename != NULL) {
g_free(priv->file_name);
priv->file_name = g_strdup(filename); priv->file_name = g_strdup(filename);
} else if (priv->file_name == NULL) {
priv->file_name = g_strdup(WMUD_CONFDIR "/wmud.conf");
}
priv->key_file = g_key_file_new(); priv->key_file = g_key_file_new();