On Thursday 14 November 2002 7:45 am, Juergen Spitzmueller wrote: > > Thereafter, FormDocument::CheckChoiceClass can go the way of the dodo > > also I think. > > But not this part: > > if (lyxrc.auto_reset_options) { > params.textclass = tc; > params.useClassDefaults(); > UpdateLayoutDocument(params); > } else { > // update the params which are needed in any case > // (fontsizes, pagestyle) > params.textclass = tc; > UpdateClassParams(params); > }
Thanks Jürgen for the feedback. I've modified CheckChoiceClass to this: void FormDocument::CheckChoiceClass(FL_OBJECT * ob, long) { BufferParams & params = controller().params(); unsigned int new_tc = combo_doc_class->get() - 1; unsigned int cur_tc = static_cast<unsigned int>(params.textclass); if (textclasslist[new_tc].load()) { params.textclass = new_tc; if (lyxrc.auto_reset_options) { params.useClassDefaults(); UpdateLayoutDocument(params); } else { // update the params which are needed in any case // (fontsizes, pagestyle) UpdateClassParams(params); } } else { combo_doc_class->select(cur_tc + 1); } } Why doesn't Qt check if the textclasslist is loadable? In fact, why don't we have a wrapper for textclasslist[new_tc].load() in the controller that posts up the warning if unsuccessful? bool ControlDocument::loadTextclass(unsigned int tc) { bool const success = textclasslist[tc].load(); if (!success) // problem changing class // -- warn user (to retain old style) Alert::alert(_("Conversion Errors!"), _("Errors loading new document class."), _("Reverting to original document class.")); } return success; } Then this stuff can come out of ControlDocument::classApply which, therefore, no longer needs to return a bool. Shall I do this? Angus