Skip to content

Commit

Permalink
Properly close abandoned new project that couldn't be written
Browse files Browse the repository at this point in the history
Also rewrite the default session in case it was cleared.
  • Loading branch information
ntrel committed Aug 27, 2014
1 parent c990cd9 commit 5964d2e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/project.c
Expand Up @@ -89,6 +89,7 @@ static void on_entries_changed(GtkEditable *editable, PropertyDialogElements *e)
static void on_radio_long_line_custom_toggled(GtkToggleButton *radio, GtkWidget *spin_long_line);
static void apply_editor_prefs(void);
static void init_stash_prefs(void);
static void destroy_project(gboolean open_default);


#define SHOW_ERR(args) dialogs_show_msgbox(GTK_MESSAGE_ERROR, args)
Expand Down Expand Up @@ -229,20 +230,26 @@ void project_new(void)
{
if (gtk_dialog_run(GTK_DIALOG(e.dialog)) != GTK_RESPONSE_OK)
{
// reload any documents that were closed
if (!app->project && !have_session_docs())
// any open docs were meant to be moved into the project
// rewrite default session because it was cleared
if (have_session_docs())
configuration_save_default_session();
else
{
// reload any documents that were closed
configuration_reload_default_session();
configuration_open_files();
}
break;
}
// dialog confirmed
if (update_config(&e, TRUE))
{
// app->project is now set
if (!write_config(TRUE))
{
SHOW_ERR(_("Project file could not be written"));
destroy_project(FALSE);
}
else
{
Expand Down Expand Up @@ -393,8 +400,6 @@ static void remove_foreach_project_filetype(gpointer data, gpointer user_data)
/* open_default will make function reload default session files on close */
void project_close(gboolean open_default)
{
GSList *node;

g_return_if_fail(app->project != NULL);

/* save project session files, etc */
Expand All @@ -408,6 +413,15 @@ void project_close(gboolean open_default)
return;
}
ui_set_statusbar(TRUE, _("Project \"%s\" closed."), app->project->name);
destroy_project(open_default);
}


static void destroy_project(gboolean open_default)
{
GSList *node;

g_return_if_fail(app->project != NULL);

/* remove project filetypes build entries */
if (app->project->priv->build_filetypes_list != NULL)
Expand Down

0 comments on commit 5964d2e

Please sign in to comment.