Highlighting: cope if Highlight subsystem is not present.
This should allow things to run ok if globals->get_subsystem<Highlight>() returns null, e.g. in a unit test or similar.
This commit is contained in:
parent
77b4e6a713
commit
5023e9786a
5 changed files with 35 additions and 20 deletions
|
@ -926,12 +926,14 @@ bool DigitalFilter::configure( SGPropertyNode& prop_root,
|
|||
collectDependentProperties(inputs);
|
||||
|
||||
Highlight* highlight = globals->get_subsystem<Highlight>();
|
||||
for (auto in: inputs) {
|
||||
for (auto& out: _output_list) {
|
||||
highlight->addPropertyProperty(
|
||||
in->getPath(true /*simplify*/),
|
||||
out->getPath(true /*simplify*/)
|
||||
);
|
||||
if (highlight) {
|
||||
for (auto in: inputs) {
|
||||
for (auto& out: _output_list) {
|
||||
highlight->addPropertyProperty(
|
||||
in->getPath(true /*simplify*/),
|
||||
out->getPath(true /*simplify*/)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -329,16 +329,19 @@ struct FdmInitialisedListener : SGPropertyChangeListener
|
|||
{
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Getting property associations from FDM");
|
||||
Highlight* highlight = globals->get_subsystem<Highlight>();
|
||||
FDMShell* fdmshell = (FDMShell*) globals->get_subsystem("flight");
|
||||
FGInterface* fginterface = fdmshell->getInterface();
|
||||
assert(fginterface);
|
||||
fginterface->property_associations(
|
||||
[highlight](const std::string& from, const std::string& to)
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "fdm property association: " << from << " => " << to);
|
||||
highlight->addPropertyProperty(from, to);
|
||||
}
|
||||
);
|
||||
if (highlight)
|
||||
{
|
||||
FDMShell* fdmshell = (FDMShell*) globals->get_subsystem("flight");
|
||||
FGInterface* fginterface = fdmshell->getInterface();
|
||||
assert(fginterface);
|
||||
fginterface->property_associations(
|
||||
[highlight](const std::string& from, const std::string& to)
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "fdm property association: " << from << " => " << to);
|
||||
highlight->addPropertyProperty(from, to);
|
||||
}
|
||||
);
|
||||
}
|
||||
s_fdm_initialised_listener.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,9 @@ static void scanMenus()
|
|||
SGPropertyNode* menubar = globals->get_props()->getNode("sim/menubar/default");
|
||||
assert(menubar);
|
||||
Highlight* highlight = globals->get_subsystem<Highlight>();
|
||||
if (!highlight) {
|
||||
return;
|
||||
}
|
||||
for (int menu_p=0; menu_p<menubar->nChildren(); ++menu_p) {
|
||||
SGPropertyNode* menu = menubar->getChild(menu_p);
|
||||
if (menu->getNameString() != "menu") continue;
|
||||
|
@ -464,7 +467,12 @@ NewGUI::readDir (const SGPath& path)
|
|||
std::vector<std::string> property_paths;
|
||||
findAllLeafValues(props, "property", property_paths);
|
||||
for (auto property_path: property_paths) {
|
||||
highlight->addPropertyDialog(property_path, name);
|
||||
// We could maybe hoist this test for hightlight to avoid reaching
|
||||
// here if it is null, but that's difficult to test, so we do it
|
||||
// here instead.
|
||||
if (highlight) {
|
||||
highlight->addPropertyDialog(property_path, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,9 @@ struct VisitorHighlight : osg::NodeVisitor
|
|||
SG_LOG(SG_GENERAL, SG_DEBUG, spaces() << "group: " << group.libraryName() << "::" << group.className());
|
||||
for (auto name: m_highlight_names)
|
||||
{
|
||||
m_highlight->addPropertyNode(name, &group);
|
||||
if (m_highlight) {
|
||||
m_highlight->addPropertyNode(name, &group);
|
||||
}
|
||||
}
|
||||
m_level += 1;
|
||||
traverse(group);
|
||||
|
@ -138,7 +140,7 @@ struct VisitorHighlight : osg::NodeVisitor
|
|||
}
|
||||
unsigned int m_level = 0; // Only used to indent diagnostics.
|
||||
std::vector<std::string> m_highlight_names;
|
||||
Highlight* m_highlight;
|
||||
Highlight* m_highlight = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1010,7 +1010,7 @@ PickList FGRenderer::pick(const osg::Vec2& windowPos)
|
|||
osg::NodePath::const_reverse_iterator npi;
|
||||
|
||||
for (npi = np.rbegin(); npi != np.rend(); ++npi) {
|
||||
if (!higlight_num_props) {
|
||||
if (!higlight_num_props && highlight) {
|
||||
higlight_num_props = highlight->highlightNodes(*npi);
|
||||
}
|
||||
SGSceneUserData* ud = SGSceneUserData::getSceneUserData(*npi);
|
||||
|
|
Loading…
Add table
Reference in a new issue