> 1. apply my patch for now. > 2. display a message box when lyx is started without proper .lst > files. This can be done easily if someone can show me where to insert > this message box. > > Because my patch follows this line, I propose that we figure out 2 for > 1.5.x, and complete 3 and 4 for 1.6.x.
OK. Here is an updated patch that does 2 as well. When lyx is started without proper .lst files, a message box will appear and say "No textclass is found. Click OK to reconfigure". After a user clicks OK, reconfigure will start. Uwe: please test. Abdel, it would be good if the output of reconfigure can appear in a dialog. Because miktex' update is very slow (25 min in my case), some progress would better be displayed. Bo
Index: src/LyX.cpp =================================================================== --- src/LyX.cpp (revision 20474) +++ src/LyX.cpp (working copy) @@ -611,6 +611,13 @@ // aknowledged. restoreGuiSession(); + // if reconfiguration is needed. + if (textclasslist.empty()) { + Alert::error(_("No textclass is found"), + _("Click OK to reconfigure lyx.")); + pimpl_->lyxfunc_.dispatch(FuncRequest(LFUN_RECONFIGURE)); + } + // Execute batch commands if available if (batch_command.empty()) return; @@ -626,6 +633,10 @@ { LyXView * view = newLyXView(); + // if there is no valid class list, do not load any file. + if (textclasslist.empty()) + return; + // if some files were specified at command-line we assume that the // user wants to edit *these* files and not to restore the session. if (!pimpl_->files_to_load_.empty()) { Index: src/TextClassList.cpp =================================================================== --- src/TextClassList.cpp (revision 20474) +++ src/TextClassList.cpp (working copy) @@ -164,13 +164,15 @@ } LYXERR(Debug::TCLASS) << "End of parsing of textclass.lst" << endl; - if (classlist_.empty()) { + // lyx will start with an empty classlist_, but only reconfigure is allowed + // in this case. This gives users a second chance to configure lyx if + // initial configuration fails. (c.f. bug 2829) + if (classlist_.empty()) lyxerr << "TextClassList::Read: no textclasses found!" << endl; - return false; - } - // Ok everything loaded ok, now sort the list. - sort(classlist_.begin(), classlist_.end(), less_textclass_avail_desc()); + else + // Ok everything loaded ok, now sort the list. + sort(classlist_.begin(), classlist_.end(), less_textclass_avail_desc()); return true; } Index: src/TextClassList.h =================================================================== --- src/TextClassList.h (revision 20474) +++ src/TextClassList.h (working copy) @@ -40,6 +40,8 @@ const_iterator begin() const { return classlist_.begin(); } /// const_iterator end() const { return classlist_.end(); } + /// + bool empty() const { return classlist_.empty(); } /// Gets textclass number from name, -1 if textclass name does not exist std::pair<bool, textclass_type> const Index: src/LyXFunc.cpp =================================================================== --- src/LyXFunc.cpp (revision 20474) +++ src/LyXFunc.cpp (working copy) @@ -390,6 +390,16 @@ //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl; FuncStatus flag; + // if textclasslist is empty, the only allowed operation is reconfigure (c.f. bug 2829) + // FIXME: this can be removed after lyx can restart itself automatically + // after reconfiguration. Note that reconfiguration is triggered at + // LyX::execBatchCommands() in LyX.cpp. + if (textclasslist.empty() && cmd.action != LFUN_RECONFIGURE + && cmd.action != LFUN_LYX_QUIT) { + flag.enabled(false); + return flag; + } + Cursor & cur = view()->cursor(); /* In LyX/Mac, when a dialog is open, the menus of the