// 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)) {
// 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;
}
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));
+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:
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());
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) {
using std::system;
#endif
-extern void LoadLyXFile(string const &);
extern void QuitLyX();
extern LyXServer * lyxserver;
// #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
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"));
// 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);
}
}