* ======================================================
*/
+#include <config.h>
+
#ifdef __GNUG__
#pragma implementation
#endif
-#include <config.h>
-
-#include <assert.h>
-#include <algorithm>
-#include <functional>
-
-#include "frontends/Alert.h"
#include "bufferlist.h"
#include "lyx_main.h"
-#include "support/FileInfo.h"
-#include "support/filetools.h"
-#include "support/lyxmanip.h"
-#include "support/lyxfunctional.h"
-#include "support/LAssert.h"
-#include "lyx_gui_misc.h"
#include "lastfiles.h"
#include "debug.h"
#include "lyxrc.h"
#include "vc-backend.h"
#include "TextCache.h"
+#include "frontends/Alert.h"
+
+#include "support/FileInfo.h"
+#include "support/filetools.h"
+#include "support/lyxmanip.h"
+#include "support/lyxfunctional.h"
+#include "support/LAssert.h"
+
+#include <cassert>
+#include <algorithm>
+#include <functional>
+
+
using std::vector;
using std::find;
using std::endl;
}
-bool BufferList::qwriteOne(Buffer * buf, string const & fname, string & unsaved_list)
+bool BufferList::qwriteOne(Buffer * buf, string const & fname,
+ string & unsaved_list)
{
bool reask = true;
while (reask) {
return false;
}
}
- return false;
+ return true;
}
bool BufferList::qwriteAll()
{
- bool are_unsaved = false;
- string unsaved;
- for (BufferStorage::iterator it = bstore.begin();
- it != bstore.end(); ++it) {
+ string unsaved;
+ BufferStorage::iterator it = bstore.begin();
+ BufferStorage::iterator end = bstore.end();
+ for (; it != end; ++it) {
if (!(*it)->isLyxClean()) {
string fname;
if ((*it)->isUnnamed())
fname = OnlyFilename((*it)->fileName());
else
fname = MakeDisplayPath((*it)->fileName(), 50);
- are_unsaved = qwriteOne(*it, fname, unsaved);
+ if (!qwriteOne(*it, fname, unsaved)) // cancel the request!
+ return false;
}
}
- if (are_unsaved && lyxrc.exit_confirmation) {
+ if (!unsaved.empty() && lyxrc.exit_confirmation) {
return Alert::askQuestion(_("Some documents were not saved:"),
- unsaved, _("Exit anyway?"));
- }
+ unsaved, _("Exit anyway?"));
+ }
- return true;
+ return true;
}
// Trace back why we need to use buf->getUser here.
// Perhaps slight rewrite is in order? (Lgb)
- if (buf->getUser()) buf->getUser()->insetUnlock();
+ if (buf->getUser())
+ buf->getUser()->insetUnlock();
+
if (buf->paragraph && !buf->isLyxClean() && !quitting) {
if (buf->getUser())
buf->getUser()->owner()->prohibitInput();
while (reask) {
switch (Alert::askConfirmation(_("Changes in document:"),
fname,
- _("Save document?"))){
+ _("Save document?"))) {
case 1: // Yes
if (buf->isUnnamed())
reask = !WriteAs(current_view, buf);
{
lyx::Assert(inset);
- //if (!inset) return 1;
- for (BufferStorage::iterator it = bstore.begin();
- it != bstore.end(); ++it) {
+ BufferStorage::iterator it = bstore.begin();
+ BufferStorage::iterator end = bstore.end();
+ for (; it != end; ++it) {
if ((*it)->getUser()
&& (*it)->getUser()->theLockingInset() == inset) {
(*it)->getUser()->insetUnlock();
void BufferList::updateIncludedTeXfiles(string const & mastertmpdir)
{
- for (BufferStorage::iterator it = bstore.begin();
- it != bstore.end(); ++it) {
+ BufferStorage::iterator it = bstore.begin();
+ BufferStorage::iterator end = bstore.end();
+ for (; it != end; ++it) {
if (!(*it)->isDepClean(mastertmpdir)) {
string writefile = mastertmpdir;
writefile += '/';
// No need to save if the buffer has not changed.
- if (buf->isLyxClean()) return;
+ if (buf->isLyxClean())
+ return;
lyxerr << fmt(_("lyx: Attempting to save document %s as..."),
buf->isUnnamed() ? OnlyFilename(buf->fileName()).c_str()
Buffer * BufferList::readFile(string const & s, bool ronly)
{
- Buffer * b = bstore.newBuffer(s, ronly);
-
- string ts = s;
+ string ts(s);
string e = OnlyPath(s);
string a = e;
// File information about normal file
return 0;
}
+ Buffer * b = bstore.newBuffer(s, ronly);
+
// Check if emergency save file exists and is newer.
e += OnlyFilename(s) + ".emergency";
FileInfo fileInfoE(e);
// How can we know _how_ to do the checkout?
// With the current VC support it has to be,
// a RCS file since CVS do not have special ,v files.
- RCS::retrive(s);
+ RCS::retrieve(s);
return loadLyXFile(filename, tolastfiles);
}
}