SF.net SVN: geany:[5769] branches/0.20.1
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun May 8 17:02:03 UTC 2011
Revision: 5769
http://geany.svn.sourceforge.net/geany/?rev=5769&view=rev
Author: eht16
Date: 2011-05-08 17:02:03 +0000 (Sun, 08 May 2011)
Log Message:
-----------
Improve error checking when trying to write project files (patch by Colomban Wendling, thanks).
Modified Paths:
--------------
branches/0.20.1/ChangeLog
branches/0.20.1/src/project.c
Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog 2011-05-08 16:51:08 UTC (rev 5768)
+++ branches/0.20.1/ChangeLog 2011-05-08 17:02:03 UTC (rev 5769)
@@ -12,6 +12,9 @@
called.
* tagmanager/php.c:
Fix memory leaks (reported by an anonymous IRC user).
+ * src/project.c:
+ Improve error checking when trying to write project files
+ (patch by Colomban Wendling, thanks).
2011-01-05 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: branches/0.20.1/src/project.c
===================================================================
--- branches/0.20.1/src/project.c 2011-05-08 16:51:08 UTC (rev 5768)
+++ branches/0.20.1/src/project.c 2011-05-08 17:02:03 UTC (rev 5769)
@@ -29,6 +29,7 @@
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include "project.h"
#include "projectprivate.h"
@@ -80,7 +81,7 @@
} PropertyDialogElements;
-static gboolean update_config(const PropertyDialogElements *e);
+static gboolean update_config(const PropertyDialogElements *e, gboolean new_project);
static void on_file_save_button_clicked(GtkButton *button, PropertyDialogElements *e);
static gboolean load_config(const gchar *filename);
static gboolean write_config(gboolean emit_signal);
@@ -189,13 +190,17 @@
while (gtk_dialog_run(GTK_DIALOG(e->dialog)) == GTK_RESPONSE_OK)
{
- if (update_config(e))
+ if (update_config(e, TRUE))
{
- write_config(TRUE);
- ui_set_statusbar(TRUE, _("Project \"%s\" created."), app->project->name);
+ if (!write_config(TRUE))
+ SHOW_ERR(_("Project file could not be written"));
+ else
+ {
+ ui_set_statusbar(TRUE, _("Project \"%s\" created."), app->project->name);
- ui_add_recent_project_file(app->project->file_name);
- break;
+ ui_add_recent_project_file(app->project->file_name);
+ break;
+ }
}
}
gtk_widget_destroy(e->dialog);
@@ -577,12 +582,16 @@
while (gtk_dialog_run(GTK_DIALOG(e->dialog)) == GTK_RESPONSE_OK)
{
- if (update_config(e))
+ if (update_config(e, FALSE))
{
g_signal_emit_by_name(geany_object, "project-dialog-confirmed", e->notebook);
- write_config(TRUE);
- ui_set_statusbar(TRUE, _("Project \"%s\" saved."), app->project->name);
- break;
+ if (!write_config(TRUE))
+ SHOW_ERR(_("Project file could not be written"));
+ else
+ {
+ ui_set_statusbar(TRUE, _("Project \"%s\" saved."), app->project->name);
+ break;
+ }
}
}
build_free_fields(e->build_properties);
@@ -644,13 +653,12 @@
/* Verifies data for New & Properties dialogs.
* Returns: FALSE if the user needs to change any data. */
-static gboolean update_config(const PropertyDialogElements *e)
+static gboolean update_config(const PropertyDialogElements *e, gboolean new_project)
{
const gchar *name, *file_name, *base_path;
gchar *locale_filename;
gint name_len;
gint err_code = 0;
- gboolean new_project = FALSE;
GeanyProject *p;
g_return_val_if_fail(e != NULL, TRUE);
@@ -670,7 +678,7 @@
return FALSE;
}
- if (app->project == NULL)
+ if (new_project)
file_name = gtk_entry_get_text(GTK_ENTRY(e->file_name));
else
file_name = gtk_label_get_text(GTK_LABEL(e->file_name));
@@ -720,7 +728,8 @@
g_free(locale_path);
}
/* finally test whether the given project file can be written */
- if ((err_code = utils_is_file_writeable(locale_filename)) != 0)
+ if ((err_code = utils_is_file_writeable(locale_filename)) != 0 ||
+ (err_code = g_file_test(locale_filename, G_FILE_TEST_IS_DIR) ? EISDIR : 0) != 0)
{
SHOW_ERR1(_("Project file could not be written (%s)."), g_strerror(err_code));
gtk_widget_grab_focus(e->file_name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list