mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 17:20:55 +00:00
Fix bug 2404
* src/lyx_cb.C (newFile): Only set the new buffer if it is valid * src/BufferView_pimpl.C (BufferView::Pimpl::loadLyXFile): Test whether newFile succeeded * src/lyxfunc.C (LyXFunc::menuNew): Only set the new buffer if it is valid (LyXFunc::open): ditto * src/importer.C (Importer::Import): ditto * src/lyx_main.C (LyX::exec2): Only use the new buffer if newFile succeeded * src/buffer_funcs.C (newFile): discard the buffer and return 0 if the template is invalid * src/BufferView_pimpl.[Ch] (BufferView::Pimpl::newFile): remove, not used anymore * src/BufferView.C (BufferView::newFile): remove, not used anymore git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@14623 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
98151fde55
commit
2a64df96f9
@ -107,12 +107,6 @@ void BufferView::setBuffer(Buffer * b)
|
||||
}
|
||||
|
||||
|
||||
void BufferView::newFile(string const & fn, string const & tn, bool named)
|
||||
{
|
||||
pimpl_->newFile(fn, tn, named);
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::loadLyXFile(string const & fn, bool tl)
|
||||
{
|
||||
return pimpl_->loadLyXFile(fn, tl);
|
||||
|
@ -92,9 +92,6 @@ public:
|
||||
|
||||
/// reload the contained buffer
|
||||
void reload();
|
||||
/// create a new buffer based on template
|
||||
void newFile(std::string const & fname, std::string const & tname,
|
||||
bool named = true);
|
||||
/// load a buffer into the view
|
||||
bool loadLyXFile(std::string const & name, bool tolastfiles = true);
|
||||
|
||||
|
@ -232,13 +232,6 @@ void BufferView::Pimpl::disconnectBuffer()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::newFile(string const & filename, string const & tname,
|
||||
bool isNamed)
|
||||
{
|
||||
setBuffer(::newFile(filename, tname, isNamed));
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
{
|
||||
// Get absolute path of file and add ".lyx"
|
||||
@ -285,9 +278,11 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
int const ret = Alert::prompt(_("Create new document?"),
|
||||
text, 0, 1, _("&Create"), _("Cancel"));
|
||||
|
||||
if (ret == 0)
|
||||
b = ::newFile(s, string(), true);
|
||||
else
|
||||
if (ret == 0) {
|
||||
b = newFile(s, string(), true);
|
||||
if (!b)
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,6 @@ public:
|
||||
///
|
||||
void update(Update::flags flags = Update::Force);
|
||||
///
|
||||
void newFile(std::string const &, std::string const &, bool);
|
||||
///
|
||||
bool loadLyXFile(std::string const &, bool);
|
||||
///
|
||||
void workAreaResize();
|
||||
|
@ -189,7 +189,8 @@ Buffer * newFile(string const & filename, string const & templatename,
|
||||
string const file = MakeDisplayPath(tname, 50);
|
||||
string const text = bformat(_("The specified document template\n%1$s\ncould not be read."), file);
|
||||
Alert::error(_("Could not read template"), text);
|
||||
// no template, start with empty buffer
|
||||
bufferlist.release(b);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "frontends/Alert.h"
|
||||
#include "gettext.h"
|
||||
#include "BufferView.h"
|
||||
#include "buffer_funcs.h"
|
||||
|
||||
using lyx::support::bformat;
|
||||
using lyx::support::ChangeExtension;
|
||||
@ -71,7 +72,11 @@ bool Importer::Import(LyXView * lv, string const & filename,
|
||||
if (loader_format == "lyx") {
|
||||
lv->view()->loadLyXFile(lyxfile);
|
||||
} else {
|
||||
lv->view()->newFile(lyxfile, string(), true);
|
||||
Buffer * const b = newFile(lyxfile, string(), true);
|
||||
if (b)
|
||||
lv->view()->setBuffer(b);
|
||||
else
|
||||
return false;
|
||||
bool as_paragraphs = loader_format == "textparagraph";
|
||||
string filename2 = (loader_format == format) ? filename
|
||||
: ChangeExtension(filename,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "buffer.h"
|
||||
#include "bufferlist.h"
|
||||
#include "BufferView.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "cursor.h"
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
@ -351,7 +352,9 @@ void NewFile(BufferView * bv, string const & filename)
|
||||
<< "\nName is " << name
|
||||
<< "\nTemplate is " << tmpname << endl;
|
||||
|
||||
bv->newFile(name, tmpname);
|
||||
Buffer * const b = newFile(name, tmpname);
|
||||
if (b)
|
||||
bv->setBuffer(b);
|
||||
}
|
||||
|
||||
|
||||
|
@ -272,7 +272,9 @@ void LyX::exec2(int & argc, char * argv[])
|
||||
// the filename if necessary
|
||||
string s = FileSearch(string(), *it, "lyx");
|
||||
if (s.empty()) {
|
||||
last_loaded = newFile(*it, string(), true);
|
||||
Buffer * const b = newFile(*it, string(), true);
|
||||
if (b)
|
||||
last_loaded = b;
|
||||
} else {
|
||||
Buffer * buf = bufferlist.newBuffer(s, false);
|
||||
buf->error.connect(boost::bind(&LyX::printError, this, _1));
|
||||
|
@ -1724,7 +1724,9 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
||||
templname = result.second;
|
||||
}
|
||||
|
||||
view()->newFile(filename, templname, !name.empty());
|
||||
Buffer * const b = newFile(filename, templname, !name.empty());
|
||||
if (b)
|
||||
view()->setBuffer(b);
|
||||
}
|
||||
|
||||
|
||||
@ -1778,8 +1780,10 @@ void LyXFunc::open(string const & fname)
|
||||
|
||||
// if the file doesn't exist, let the user create one
|
||||
if (!fs::exists(filename)) {
|
||||
// the user specifically chose this name. Believe them.
|
||||
view()->newFile(filename, "", true);
|
||||
// the user specifically chose this name. Believe him.
|
||||
Buffer * const b = newFile(filename, string(), true);
|
||||
if (b)
|
||||
view()->setBuffer(b);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,9 @@ What's new
|
||||
|
||||
- Fix the C-x C-b binding in emacs mode (bug 2747).
|
||||
|
||||
- Fix a crash when a non-template file is selected in the
|
||||
"New from Template" dialog (bug 2404)
|
||||
|
||||
* Build/installation:
|
||||
|
||||
- Fix 'check' make target for systems which do not have /bin/bash (bug 2524).
|
||||
|
Loading…
Reference in New Issue
Block a user