state_file: simplified state_file_finish()
Return early from the destructor function when there is no configured state file. Don't check the timer, don't call g_free(NULL).
This commit is contained in:
parent
889b1c1eae
commit
df7d7732c6
@ -41,8 +41,7 @@ state_file_write(void)
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (state_file_path == NULL)
|
assert(state_file_path != NULL);
|
||||||
return;
|
|
||||||
|
|
||||||
g_debug("Saving state file %s", state_file_path);
|
g_debug("Saving state file %s", state_file_path);
|
||||||
|
|
||||||
@ -114,11 +113,14 @@ state_file_init(const char *path)
|
|||||||
void
|
void
|
||||||
state_file_finish(void)
|
state_file_finish(void)
|
||||||
{
|
{
|
||||||
|
if (state_file_path == NULL)
|
||||||
|
/* no state file configured, no cleanup required */
|
||||||
|
return;
|
||||||
|
|
||||||
if (save_state_source_id != 0)
|
if (save_state_source_id != 0)
|
||||||
g_source_remove(save_state_source_id);
|
g_source_remove(save_state_source_id);
|
||||||
|
|
||||||
if (state_file_path != NULL)
|
state_file_write();
|
||||||
state_file_write();
|
|
||||||
|
|
||||||
g_free(state_file_path);
|
g_free(state_file_path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user