> The patch to configure.py looks good to me. Concerning the lyx part,
> in which cases is this situation supposed to happen exactly?
Under any weird case that textclass fails to load, and results in an
empty textclasslist.
I have submitted the configure.py part. Attached is an update lyx part.
1. allow option to configure.py
-void reconfigure(LyXView & lv)
+void reconfigure(LyXView & lv, string const & option)
{
// emit message signal.
lv.message(_("Running configure..."));
// Run configure in user lyx directory
support::Path p(package().user_support());
- string const configure_command = package().configure_command();
+ string configure_command = package().configure_command();
+ configure_command += option;
2. allow LFUN_RECONFIGURE with option
case LFUN_RECONFIGURE:
BOOST_ASSERT(lyx_view_);
- reconfigure(*lyx_view_);
+ // argument is any additional parameter to the
configure.py command
+ reconfigure(*lyx_view_, argument);
break;
3. When textclasslist is empty, allow regular configure, configure
with --without-latex-config, and quit. Quit lyx after reconfigure.
Index: src/LyX.cpp
===================================================================
--- src/LyX.cpp (revision 20517)
+++ src/LyX.cpp (working copy)
@@ -611,6 +611,31 @@
// aknowledged.
restoreGuiSession();
+ // if reconfiguration is needed.
+ if (textclasslist.empty()) {
+ switch (Alert::prompt(
+ _("No textclass is found"),
+ _("LyX can not continue because no textclass is found. "
+ "You can either reconfigure normally, or reconfigure
using "
+ "default text classes, or quit lyx."),
+ 0, 2,
+ _("&Reconfigure"),
+ _("&Use Default"),
+ _("&Exit LyX")))
+ {
+ case 0:
+ // regular reconfigure
+ pimpl_->lyxfunc_.dispatch(FuncRequest(LFUN_RECONFIGURE,
""));
+ break;
+ case 1:
+ // reconfigure --without-latex-config
+ pimpl_->lyxfunc_.dispatch(FuncRequest(LFUN_RECONFIGURE,
"
--without-latex-config"));
+ break;
+ }
+ pimpl_->lyxfunc_.dispatch(FuncRequest(LFUN_LYX_QUIT));
+ return;
+ }
+
// Execute batch commands if available
if (batch_command.empty())
return;
4. Other parts are the same.
Can I apply?
Bo
Index: src/callback.h
===================================================================
--- src/callback.h (revision 20517)
+++ src/callback.h (working copy)
@@ -37,7 +37,7 @@
docstring const getContentsOfPlaintextFile(BufferView * bv,
std::string const & f, bool asParagraph);
///
-void reconfigure(LyXView & lv);
+void reconfigure(LyXView & lv, std::string const & option);
} // namespace lyx
Index: src/LyX.cpp
===================================================================
--- src/LyX.cpp (revision 20517)
+++ src/LyX.cpp (working copy)
@@ -611,6 +611,31 @@
// aknowledged.
restoreGuiSession();
+ // if reconfiguration is needed.
+ if (textclasslist.empty()) {
+ switch (Alert::prompt(
+ _("No textclass is found"),
+ _("LyX can not continue because no textclass is found. "
+ "You can either reconfigure normally, or reconfigure using "
+ "default text classes, or quit lyx."),
+ 0, 2,
+ _("&Reconfigure"),
+ _("&Use Default"),
+ _("&Exit LyX")))
+ {
+ case 0:
+ // regular reconfigure
+ pimpl_->lyxfunc_.dispatch(FuncRequest(LFUN_RECONFIGURE, ""));
+ break;
+ case 1:
+ // reconfigure --without-latex-config
+ pimpl_->lyxfunc_.dispatch(FuncRequest(LFUN_RECONFIGURE, " --without-latex-config"));
+ break;
+ }
+ pimpl_->lyxfunc_.dispatch(FuncRequest(LFUN_LYX_QUIT));
+ return;
+ }
+
// Execute batch commands if available
if (batch_command.empty())
return;
@@ -626,6 +651,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 20517)
+++ 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/callback.cpp
===================================================================
--- src/callback.cpp (revision 20517)
+++ src/callback.cpp (working copy)
@@ -434,14 +434,15 @@
// This function runs "configure" and then rereads lyx.defaults to
// reconfigure the automatic settings.
-void reconfigure(LyXView & lv)
+void reconfigure(LyXView & lv, string const & option)
{
// emit message signal.
lv.message(_("Running configure..."));
// Run configure in user lyx directory
support::Path p(package().user_support());
- string const configure_command = package().configure_command();
+ string configure_command = package().configure_command();
+ configure_command += option;
Systemcall one;
one.startscript(Systemcall::Wait, configure_command);
p.pop();
Index: src/TextClassList.h
===================================================================
--- src/TextClassList.h (revision 20517)
+++ 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 20517)
+++ src/LyXFunc.cpp (working copy)
@@ -1178,7 +1178,8 @@
case LFUN_RECONFIGURE:
BOOST_ASSERT(lyx_view_);
- reconfigure(*lyx_view_);
+ // argument is any additional parameter to the configure.py command
+ reconfigure(*lyx_view_, argument);
break;
case LFUN_HELP_OPEN: {