mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
First step toward fixing http://bugzilla.lyx.org/show_bug.cgi?id=3243
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25955 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
72d9237817
commit
5ac9db6dfc
@ -25,6 +25,7 @@
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/FileName.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Package.h"
|
||||
@ -273,8 +274,10 @@ docstring BufferList::emergencyWrite(Buffer * buf)
|
||||
}
|
||||
|
||||
|
||||
bool BufferList::exists(string const & s) const
|
||||
bool BufferList::exists(FileName const & fname) const
|
||||
{
|
||||
//FIXME: use Buffer::fileName()!
|
||||
string const s = fname.absFilename();
|
||||
return find_if(bstore.begin(), bstore.end(),
|
||||
bind(equal_to<string>(),
|
||||
bind(&Buffer::absFileName, _1),
|
||||
|
@ -22,6 +22,10 @@ namespace lyx {
|
||||
class Buffer;
|
||||
class OutputParams;
|
||||
|
||||
namespace support {
|
||||
class FileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class holds all all open buffers, and handles construction
|
||||
* and deletions of new ones.
|
||||
@ -79,7 +83,7 @@ public:
|
||||
Buffer * last();
|
||||
|
||||
/// returns true if the buffer exists already
|
||||
bool exists(std::string const &) const;
|
||||
bool exists(support::FileName const &) const;
|
||||
|
||||
/// returns true if the buffer is loaded
|
||||
bool isLoaded(Buffer const * b) const;
|
||||
|
@ -246,14 +246,14 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
|
||||
LASSERT(!bm.filename.empty(), /**/);
|
||||
string const file = bm.filename.absFilename();
|
||||
// if the file is not opened, open it.
|
||||
if (!theBufferList().exists(file)) {
|
||||
if (!theBufferList().exists(bm.filename)) {
|
||||
if (openFile)
|
||||
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
||||
else
|
||||
return;
|
||||
}
|
||||
// open may fail, so we need to test it again
|
||||
if (!theBufferList().exists(file))
|
||||
if (!theBufferList().exists(bm.filename))
|
||||
return;
|
||||
|
||||
// if the current buffer is not that one, switch to it.
|
||||
@ -1109,7 +1109,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
// and get full path
|
||||
FileName const s = fileSearch(string(), changeExtension(file_name, ".lyx"), "lyx");
|
||||
// Either change buffer or load the file
|
||||
if (theBufferList().exists(s.absFilename()))
|
||||
if (theBufferList().exists(s))
|
||||
buf = theBufferList().getBuffer(s.absFilename());
|
||||
else {
|
||||
buf = lyx_view_->loadDocument(s);
|
||||
@ -1266,7 +1266,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
view()->saveBookmark(false);
|
||||
Buffer * child = 0;
|
||||
bool parsed = false;
|
||||
if (theBufferList().exists(filename.absFilename())) {
|
||||
if (theBufferList().exists(filename)) {
|
||||
child = theBufferList().getBuffer(filename.absFilename());
|
||||
} else {
|
||||
setMessage(bformat(_("Opening child document %1$s..."),
|
||||
|
@ -153,16 +153,15 @@ Buffer * newUnnamedFile(string const & templatename, FileName const & path)
|
||||
{
|
||||
static int newfile_number;
|
||||
|
||||
string document_path = path.absFilename();
|
||||
string filename = addName(document_path,
|
||||
FileName filename(path,
|
||||
"newfile" + convert<string>(++newfile_number) + ".lyx");
|
||||
while (theBufferList().exists(filename)
|
||||
|| FileName(filename).isReadableFile()) {
|
||||
|| filename.isReadableFile()) {
|
||||
++newfile_number;
|
||||
filename = addName(document_path,
|
||||
filename.set(path,
|
||||
"newfile" + convert<string>(newfile_number) + ".lyx");
|
||||
}
|
||||
return newFile(filename, templatename, false);
|
||||
return newFile(filename.absFilename(), templatename, false);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user