Kaydet (Commit) 554ccd4f authored tarafından Enrico Tröger's avatar Enrico Tröger

Mark the document only as changed if it is not closed afterwards.

Prevent possible segfaults if the document was closed when it is missing from the filesystem.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4501 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 6fdf1cdf
......@@ -12,6 +12,9 @@
* src/document.c:
When closing a document after it was deleted from the filesystem,
don't ask whether it should be saved first.
Mark the document only as changed if it is not closed afterwards.
Prevent possible segfaults if the document was closed when it is
missing from the filesystem.
* src/keybindings.c, src/keyfile.c, src/main.c, src/msgwindow.c,
src/msgwindow.h, src/prefs.c:
Add MessageWindow::scribble and use it instead of searching the
......
......@@ -2948,11 +2948,6 @@ static gboolean monitor_resave_missing_file(GeanyDocument *doc)
gboolean want_reload = FALSE;
gint ret;
/* file is missing - set unsaved state */
document_set_text_changed(doc, TRUE);
/* don't prompt more than once */
setptr(doc->real_path, NULL);
ret = dialogs_show_prompt(NULL,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
......@@ -2966,9 +2961,15 @@ static gboolean monitor_resave_missing_file(GeanyDocument *doc)
}
else if (ret == GTK_RESPONSE_CLOSE)
{
doc->changed = FALSE;
document_close(doc);
}
if (ret != GTK_RESPONSE_CLOSE)
{
/* file is missing - set unsaved state */
document_set_text_changed(doc, TRUE);
/* don't prompt more than once */
setptr(doc->real_path, NULL);
}
return want_reload;
}
......@@ -3027,11 +3028,13 @@ gboolean document_check_disk_status(GeanyDocument *doc, gboolean force)
}
g_free(locale_filename);
old_status = doc->priv->file_disk_status;
doc->priv->file_disk_status = FILE_OK;
if (old_status != doc->priv->file_disk_status)
ui_update_tab_status(doc);
if (DOC_VALID(doc))
{ /* doc can get invalid when a document was closed by monitor_resave_missing_file() */
old_status = doc->priv->file_disk_status;
doc->priv->file_disk_status = FILE_OK;
if (old_status != doc->priv->file_disk_status)
ui_update_tab_status(doc);
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment