mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Fix crash when changing text class.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8569 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
72f045c60f
commit
2baeac64ff
@ -1,3 +1,11 @@
|
||||
2004-03-31 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyxfunc.C (loadTextclass): new helper function, invoked by two of
|
||||
dispatch's case blocks, LFUN_TEXTCLASS_APPLY and LFUN_TEXTCLASS_LOAD.
|
||||
|
||||
* lyxtextclass.C (load): if the text class couldn't be loaded, then
|
||||
don't overwrite 'loaded_ = false' with 'loaded_ = true' !
|
||||
|
||||
2004-03-31 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* lyxfunc.C (dispatch): remove the cursor-manipulation code from
|
||||
|
@ -551,6 +551,7 @@ bool ensureBufferClean(BufferView * bv)
|
||||
return buf.isClean();
|
||||
}
|
||||
|
||||
|
||||
void showPrintError(string const & name)
|
||||
{
|
||||
string str = bformat(_("Could not print the document %1$s.\n"
|
||||
@ -559,6 +560,29 @@ void showPrintError(string const & name)
|
||||
Alert::error(_("Print document failed"), str);
|
||||
}
|
||||
|
||||
|
||||
void loadTextclass(string const & name)
|
||||
{
|
||||
std::pair<bool, lyx::textclass_type> const tc_pair =
|
||||
textclasslist.NumberOfClass(name);
|
||||
|
||||
if (!tc_pair.first) {
|
||||
lyxerr << "Document class \"" << name
|
||||
<< "\" does not exist."
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
lyx::textclass_type const tc = tc_pair.second;
|
||||
|
||||
if (!textclasslist[tc].load()) {
|
||||
string s = bformat(_("The document could not be converted\n"
|
||||
"into the document class %1$s."),
|
||||
textclasslist[tc].name());
|
||||
Alert::error(_("Could not change class"), s);
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace anon
|
||||
|
||||
|
||||
@ -1313,7 +1337,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
|
||||
lyx::textclass_type const old_class =
|
||||
buffer->params().textclass;
|
||||
|
||||
dispatch(FuncRequest(LFUN_TEXTCLASS_LOAD, argument));
|
||||
loadTextclass(argument);
|
||||
|
||||
std::pair<bool, lyx::textclass_type> const tc_pair =
|
||||
textclasslist.NumberOfClass(argument);
|
||||
@ -1339,30 +1363,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_TEXTCLASS_LOAD: {
|
||||
std::pair<bool, lyx::textclass_type> const tc_pair =
|
||||
textclasslist.NumberOfClass(argument);
|
||||
|
||||
if (!tc_pair.first) {
|
||||
lyxerr << "Document class \"" << argument
|
||||
<< "\" does not exist."
|
||||
<< std::endl;
|
||||
case LFUN_TEXTCLASS_LOAD:
|
||||
loadTextclass(argument);
|
||||
break;
|
||||
}
|
||||
|
||||
lyx::textclass_type const tc = tc_pair.second;
|
||||
|
||||
bool const success = textclasslist[tc].load();
|
||||
if (success)
|
||||
break;
|
||||
|
||||
string s = bformat(_("The document could not be converted\n"
|
||||
"into the document class %1$s."),
|
||||
textclasslist[tc].name());
|
||||
Alert::error(_("Could not change class"), s);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
DispatchResult res = view()->cursor().dispatch(cmd);
|
||||
|
@ -845,16 +845,16 @@ bool LyXTextClass::load() const
|
||||
|
||||
// Read style-file
|
||||
string const real_file = LibFileSearch("layouts", name_, "layout");
|
||||
loaded_ = const_cast<LyXTextClass*>(this)->Read(real_file) == 0;
|
||||
|
||||
if (const_cast<LyXTextClass*>(this)->Read(real_file)) {
|
||||
if (!loaded_) {
|
||||
lyxerr << "Error reading `"
|
||||
<< MakeDisplayPath(real_file)
|
||||
<< "'\n(Check `" << name_
|
||||
<< "')\nCheck your installation and "
|
||||
"try Options/Reconfigure..." << endl;
|
||||
loaded_ = false;
|
||||
}
|
||||
loaded_ = true;
|
||||
|
||||
return loaded_;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user