From 557f9688755564108e756b0de9dea1e9be2c7924 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 2 Mar 2012 20:34:41 +0100 Subject: [PATCH] Don't overwrite variables stored in file_monitor (Closes: #120) --- zathura.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/zathura.c b/zathura.c index 8850de9..cf6b29c 100644 --- a/zathura.c +++ b/zathura.c @@ -418,24 +418,30 @@ document_open(zathura_t* zathura, const char* path, const char* password) goto error_free; } - zathura->file_monitor.file = g_file_new_for_uri(file_uri); if (zathura->file_monitor.file == NULL) { - goto error_free; + zathura->file_monitor.file = g_file_new_for_uri(file_uri); + if (zathura->file_monitor.file == NULL) { + goto error_free; + } } - zathura->file_monitor.monitor = g_file_monitor_file(zathura->file_monitor.file, G_FILE_MONITOR_NONE, NULL, NULL); if (zathura->file_monitor.monitor == NULL) { - goto error_free; + zathura->file_monitor.monitor = g_file_monitor_file(zathura->file_monitor.file, G_FILE_MONITOR_NONE, NULL, NULL); + if (zathura->file_monitor.monitor == NULL) { + goto error_free; + } + g_signal_connect(G_OBJECT(zathura->file_monitor.monitor), "changed", G_CALLBACK(cb_file_monitor), zathura->ui.session); } - g_signal_connect(G_OBJECT(zathura->file_monitor.monitor), "changed", G_CALLBACK(cb_file_monitor), zathura->ui.session); - - zathura->file_monitor.file_path = g_strdup(document->file_path); if (zathura->file_monitor.file_path == NULL) { - goto error_free; + zathura->file_monitor.file_path = g_strdup(document->file_path); + if (zathura->file_monitor.file_path == NULL) { + goto error_free; + } } if (document->password != NULL) { + g_free(zathura->file_monitor.password); zathura->file_monitor.password = g_strdup(document->password); if (zathura->file_monitor.password == NULL) { goto error_free;