mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Fix crash in lyx -e latex lib/doc/Shortcuts.lyx: theApp() is 0 in batch mode.
Unfortunately the commandline export of InsetInfo is still broken for MENU_INFO. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37134 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
006a906858
commit
a89dbd75e6
@ -48,6 +48,8 @@ Branch::Branch()
|
||||
// no theApp() with command line export
|
||||
if (theApp())
|
||||
theApp()->getRgbColor(Color_background, color_);
|
||||
else
|
||||
frontend::Application::getRgbColorUncached(Color_background, color_);
|
||||
}
|
||||
|
||||
|
||||
@ -106,9 +108,14 @@ void Branch::setColor(string const & str)
|
||||
{
|
||||
if (str.size() == 7 && str[0] == '#')
|
||||
color_ = rgbFromHexName(str);
|
||||
else
|
||||
else {
|
||||
// no color set or invalid color - use normal background
|
||||
theApp()->getRgbColor(Color_background, color_);
|
||||
// no theApp() with command line export
|
||||
if (theApp())
|
||||
theApp()->getRgbColor(Color_background, color_);
|
||||
else
|
||||
frontend::Application::getRgbColorUncached(Color_background, color_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,6 +69,8 @@ Index::Index()
|
||||
// no theApp() with command line export
|
||||
if (theApp())
|
||||
theApp()->getRgbColor(Color_indexlabel, color_);
|
||||
else
|
||||
frontend::Application::getRgbColorUncached(Color_indexlabel, color_);
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +114,14 @@ void Index::setColor(string const & str)
|
||||
{
|
||||
if (str.size() == 7 && str[0] == '#')
|
||||
color_ = rgbFromHexName(str);
|
||||
else
|
||||
else {
|
||||
// no color set or invalid color -- use predefined color
|
||||
theApp()->getRgbColor(Color_indexlabel, color_);
|
||||
// no theApp() with command line export
|
||||
if (theApp())
|
||||
theApp()->getRgbColor(Color_indexlabel, color_);
|
||||
else
|
||||
frontend::Application::getRgbColorUncached(Color_indexlabel, color_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,6 +209,8 @@ public:
|
||||
* It returns false on failure and sets r, g, b to 0.
|
||||
*/
|
||||
virtual bool getRgbColor(ColorCode col, RGBColor & rgbcol) = 0;
|
||||
/// Like getRgbColor(), but static and slower
|
||||
static bool getRgbColorUncached(ColorCode col, RGBColor & rgbcol);
|
||||
|
||||
/** Eg, passing Color_black returns "000000",
|
||||
* passing Color_white returns "ffffff".
|
||||
@ -232,7 +234,7 @@ public:
|
||||
docstring_list & names) const = 0;
|
||||
|
||||
/// \return the icon file name for the given action.
|
||||
virtual docstring iconName(FuncRequest const & f, bool unknown) = 0;
|
||||
static docstring iconName(FuncRequest const & f, bool unknown);
|
||||
|
||||
/// Handle a accented char key sequence
|
||||
/// FIXME: this is only needed for LFUN_ACCENT_* in Text::dispatch()
|
||||
|
@ -849,7 +849,7 @@ void GuiApplication::clearSession()
|
||||
}
|
||||
|
||||
|
||||
docstring GuiApplication::iconName(FuncRequest const & f, bool unknown)
|
||||
docstring Application::iconName(FuncRequest const & f, bool unknown)
|
||||
{
|
||||
return qstring_to_ucs4(lyx::frontend::iconName(f, unknown));
|
||||
}
|
||||
@ -2182,6 +2182,22 @@ bool GuiApplication::getRgbColor(ColorCode col, RGBColor & rgbcol)
|
||||
}
|
||||
|
||||
|
||||
bool Application::getRgbColorUncached(ColorCode col, RGBColor & rgbcol)
|
||||
{
|
||||
QColor const qcol(lcolor.getX11Name(col).c_str());
|
||||
if (!qcol.isValid()) {
|
||||
rgbcol.r = 0;
|
||||
rgbcol.g = 0;
|
||||
rgbcol.b = 0;
|
||||
return false;
|
||||
}
|
||||
rgbcol.r = qcol.red();
|
||||
rgbcol.g = qcol.green();
|
||||
rgbcol.b = qcol.blue();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
string const GuiApplication::hexName(ColorCode col)
|
||||
{
|
||||
return ltrim(fromqstr(d->color_cache_.get(col).name()), "#");
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
void registerSocketCallback(int fd, SocketCallback func);
|
||||
void unregisterSocketCallback(int fd);
|
||||
bool searchMenu(FuncRequest const & func, docstring_list & names) const;
|
||||
docstring iconName(FuncRequest const & f, bool unknown);
|
||||
void handleKeyFunc(FuncCode action);
|
||||
//@}
|
||||
|
||||
|
@ -358,6 +358,10 @@ void InsetInfo::updateInfo()
|
||||
break;
|
||||
}
|
||||
// iterate through the menubackend to find it
|
||||
if (!theApp()) {
|
||||
error("Can't determine menu entry for action %1$s in batch mode");
|
||||
break;
|
||||
}
|
||||
if (!theApp()->searchMenu(func, names)) {
|
||||
error("No menu entry for action %1$s");
|
||||
break;
|
||||
@ -389,11 +393,15 @@ void InsetInfo::updateInfo()
|
||||
}
|
||||
case ICON_INFO: {
|
||||
FuncRequest func = lyxaction.lookupFunc(name_);
|
||||
docstring icon_name = theApp()->iconName(func, true);
|
||||
docstring icon_name = frontend::Application::iconName(func, true);
|
||||
//FIXME: We should use the icon directly instead of
|
||||
// going through FileName. The code below won't work
|
||||
// if the icon is embedded in the executable through
|
||||
// the Qt resource system.
|
||||
// This is only a negligible performance problem:
|
||||
// If the installed icon differs from the resource icon the
|
||||
// installed one is preferred anyway, and all icons that are
|
||||
// embedded in the resources are installed as well.
|
||||
FileName file(to_utf8(icon_name));
|
||||
if (!file.exists())
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user