mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
Fix to Bug 1287 and Bug 1297
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7443 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
93ea6f14a0
commit
5fb7795b10
@ -188,9 +188,11 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
// get absolute path of file and add ".lyx" to the filename if
|
||||
// necessary
|
||||
string s = FileSearch(string(), filename, "lyx");
|
||||
if (s.empty()) {
|
||||
|
||||
bool const found = !s.empty();
|
||||
|
||||
if (!found)
|
||||
s = filename;
|
||||
}
|
||||
|
||||
// file already open?
|
||||
if (bufferlist.exists(s)) {
|
||||
@ -211,29 +213,35 @@ bool BufferView::Pimpl::loadLyXFile(string const & filename, bool tolastfiles)
|
||||
// Fall through to new load. (Asger)
|
||||
}
|
||||
}
|
||||
Buffer * b = bufferlist.newBuffer(s);
|
||||
|
||||
connectBuffer(*b);
|
||||
Buffer * b;
|
||||
|
||||
if (! ::loadLyXFile(b, s)) {
|
||||
bufferlist.release(b);
|
||||
if (found) {
|
||||
b = bufferlist.newBuffer(s);
|
||||
connectBuffer(*b);
|
||||
if (!::loadLyXFile(b, s)) {
|
||||
bufferlist.release(b);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
string text = bformat(_("The document %1$s does not yet "
|
||||
"exist.\n\nDo you want to create "
|
||||
"a new document?"), s);
|
||||
int const ret = Alert::prompt(_("Create new document?"),
|
||||
text, 0, 1, _("&Create"), _("Cancel"));
|
||||
|
||||
if (ret != 0)
|
||||
if (ret == 0)
|
||||
b = ::newFile(s, string(), true);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer(b);
|
||||
bv_->showErrorList(_("Parse"));
|
||||
|
||||
if (tolastfiles)
|
||||
lastfiles->newFile(b->fileName());
|
||||
|
||||
bv_->showErrorList(_("Parse"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -281,18 +289,16 @@ void BufferView::Pimpl::buffer(Buffer * b)
|
||||
return;
|
||||
|
||||
// if we are closing the buffer, use the first buffer as current
|
||||
if (!buffer_) {
|
||||
if (!buffer_)
|
||||
buffer_ = bufferlist.first();
|
||||
}
|
||||
|
||||
if (buffer_) {
|
||||
lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl;
|
||||
connectBuffer(*buffer_);
|
||||
|
||||
// If we don't have a text object for this, we make one
|
||||
if (bv_->text == 0) {
|
||||
if (bv_->text == 0)
|
||||
resizeCurrentBuffer();
|
||||
}
|
||||
|
||||
// FIXME: needed when ?
|
||||
bv_->text->top_y(screen().topCursorVisible(bv_->text));
|
||||
|
@ -1,3 +1,9 @@
|
||||
2003-07-29 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* lyx_main.C (LyX):
|
||||
* BufferView_pimpl.C (loadLyXFile): fix to bugs 1287 and 1297 + ws
|
||||
|
||||
|
||||
2003-07-29 Martin Vermeer <martin.vermeer@hut.fi>
|
||||
|
||||
* LaTeXFeatures.C:
|
||||
|
@ -163,8 +163,7 @@ Buffer * newFile(string const & filename, string const & templatename,
|
||||
if (!tname.empty()) {
|
||||
if (!b->readFile(tname)) {
|
||||
string const file = MakeDisplayPath(tname, 50);
|
||||
string const text = bformat(_("The specified document template\n%1$s\n"
|
||||
"could not be read."), file);
|
||||
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
|
||||
b->paragraphs.push_back(Paragraph());
|
||||
|
@ -290,9 +290,8 @@ void start(string const & batch, vector<string> const & files)
|
||||
view.view()->loadLyXFile(*cit, true);
|
||||
|
||||
// handle the batch commands the user asked for
|
||||
if (!batch.empty()) {
|
||||
if (!batch.empty())
|
||||
view.getLyXFunc().dispatch(batch);
|
||||
}
|
||||
|
||||
// enter the event loop
|
||||
while (!finished) {
|
||||
|
@ -59,7 +59,6 @@ using std::signal;
|
||||
using std::system;
|
||||
#endif
|
||||
|
||||
extern void LoadLyXFile(string const &);
|
||||
extern void QuitLyX();
|
||||
|
||||
extern LyXServer * lyxserver;
|
||||
@ -97,9 +96,8 @@ LyX::LyX(int & argc, char * argv[])
|
||||
// #include "graphics/GraphicsTypes.h" at the top -- Rob Lahaye.
|
||||
lyx::graphics::setDisplayTranslator();
|
||||
|
||||
if (want_gui) {
|
||||
if (want_gui)
|
||||
lyx_gui::parse_init(argc, argv);
|
||||
}
|
||||
|
||||
// check for any spurious extra arguments
|
||||
// other than documents
|
||||
@ -116,15 +114,13 @@ LyX::LyX(int & argc, char * argv[])
|
||||
init(want_gui);
|
||||
lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
|
||||
|
||||
if (want_gui) {
|
||||
if (want_gui)
|
||||
lyx_gui::parse_lyxrc();
|
||||
}
|
||||
|
||||
vector<string> files;
|
||||
|
||||
for (int argi = argc - 1; argi >= 1; --argi) {
|
||||
for (int argi = argc - 1; argi >= 1; --argi)
|
||||
files.push_back(argv[argi]);
|
||||
}
|
||||
|
||||
if (first_start)
|
||||
files.push_back(i18nLibFileSearch("examples", "splash.lyx"));
|
||||
@ -145,14 +141,14 @@ LyX::LyX(int & argc, char * argv[])
|
||||
// the filename if necessary
|
||||
string s = FileSearch(string(), *it, "lyx");
|
||||
if (s.empty()) {
|
||||
last_loaded = newFile(*it, "");
|
||||
last_loaded = newFile(*it, string(), true);
|
||||
} else {
|
||||
last_loaded = bufferlist.newBuffer(s, false);
|
||||
last_loaded->error.connect(boost::bind(&LyX::printError, this, _1));
|
||||
if (!loadLyXFile(last_loaded, s)) {
|
||||
bufferlist.release(last_loaded);
|
||||
last_loaded = newFile(*it, string());
|
||||
}
|
||||
Buffer * buf = bufferlist.newBuffer(s, false);
|
||||
buf->error.connect(boost::bind(&LyX::printError, this, _1));
|
||||
if (loadLyXFile(buf, s))
|
||||
last_loaded = buf;
|
||||
else
|
||||
bufferlist.release(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user