From: James Turner Date: Mon, 28 Sep 2015 20:12:46 +0000 (-0500) Subject: Developer-warnings X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2314ccfe13e5e175763000e4c8ba86be79aa3a97;p=flightgear.git Developer-warnings - make some existing warnings developer-mode only - add a warning about legacy aircraft path usage --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 65d287ce4..816fa80d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ if(COMMAND cmake_policy) if(POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() + # Mac RPATH policy if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) endif() @@ -171,6 +172,7 @@ option(SYSTEM_GSM "Set to ON to build IAXClient with the system's GSM lib option(SYSTEM_FLITE "Set to ON to build Flightgear with the system's Flite library" ${SYSTEM_FLITE_DEFAULT}) option(SYSTEM_HTS_ENGINE "Set to ON to build Flightgear with the system's HTS Engine library" ${SYSTEM_HTS_ENGINE_DEFAULT}) option(FG_NIGHTLY "Set to ON to mark this as a nightly build" OFF) +option(ENABLE_DEV_WARNINGS "Set to ON to include developer-warnings" OFF) # additional utilities option(ENABLE_FGADMIN "Set to ON to build the FGADMIN application (default)" ON) diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index cb4dc592c..b3000f9a3 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -576,8 +576,11 @@ void FGSubmodelMgr::setData(int id, const string& path, bool serviceable, const sm->pitch_offset = new FGXMLAutopilot::InputValue(*prop_root, b ? *b : n); if (b) old = true; - if (old) +#if defined(ENABLE_DEV_WARNINGS) + if (old) { SG_LOG(SG_AI, SG_WARN, "Submodels: <*-offset> is deprecated. Use instead"); + } +#endif } // Randomness diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index e6e720385..907166171 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -222,9 +222,11 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts) if(a->hasAttribute("version")) { _airplane.setVersion( a->getValue("version") ); } +#if defined(ENABLE_DEV_WARNINGS) if( !_airplane.isVersionOrNewer( Version::YASIM_VERSION_CURRENT ) ) { SG_LOG(SG_FLIGHT,SG_ALERT, "This aircraft does not use the latest yasim configuration version."); } +#endif } else if(eq(name, "approach")) { float spd = attrf(a, "speed") * KTS2MPS; float alt = attrf(a, "alt", 0) * FT2M; diff --git a/src/Include/config_cmake.h.in b/src/Include/config_cmake.h.in index ec9c1bc07..9989badf2 100644 --- a/src/Include/config_cmake.h.in +++ b/src/Include/config_cmake.h.in @@ -50,3 +50,5 @@ #cmakedefine ENABLE_FLITE #cmakedefine HAVE_QT + +#cmakedefine ENABLE_DEV_WARNINGS diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 8812564a1..f0ce2354e 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -71,24 +71,34 @@ public: simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH) { } - + virtual SGPath resolve(const std::string& aResource, SGPath&) const { string_list pieces(sgPathBranchSplit(aResource)); if ((pieces.size() < 3) || (pieces.front() != "Aircraft")) { return SGPath(); // not an Aircraft path } - + // test against the aircraft-dir property const char* aircraftDir = fgGetString("/sim/aircraft-dir"); string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir)); if (!aircraftDirPieces.empty() && (aircraftDirPieces.back() == pieces[1])) { + // disable this warning for release builds +#if defined(ENABLE_DEV_WARNINGS) + SGPath betterPath; + for (unsigned int i=2; iget_aircraft_paths()); @@ -109,7 +119,7 @@ public: return p; } } // of aircraft path iteration - + return SGPath(); // not found } }; @@ -121,7 +131,7 @@ public: simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH) { } - + virtual SGPath resolve(const std::string& aResource, SGPath&) const { const char* aircraftDir = fgGetString("/sim/aircraft-dir"); @@ -163,7 +173,7 @@ FGGlobals::FGGlobals() : SGPropertyNode* root = new SGPropertyNode; props = SGPropertyNode_ptr(root); locale = new FGLocale(props); - + simgear::ResourceManager::instance()->addProvider(new AircraftResourceProvider); simgear::ResourceManager::instance()->addProvider(new CurrentAircraftDirProvider); initProperties(); @@ -172,15 +182,15 @@ FGGlobals::FGGlobals() : void FGGlobals::initProperties() { simgear::PropertyObjectBase::setDefaultRoot(props); - + positionLon = props->getNode("position/longitude-deg", true); positionLat = props->getNode("position/latitude-deg", true); positionAlt = props->getNode("position/altitude-ft", true); - + viewLon = props->getNode("sim/current-view/viewer-lon-deg", true); viewLat = props->getNode("sim/current-view/viewer-lat-deg", true); viewAlt = props->getNode("sim/current-view/viewer-elev-ft", true); - + orientPitch = props->getNode("orientation/pitch-deg", true); orientHeading = props->getNode("orientation/heading-deg", true); orientRoll = props->getNode("orientation/roll-deg", true); @@ -188,7 +198,7 @@ void FGGlobals::initProperties() } // Destructor -FGGlobals::~FGGlobals() +FGGlobals::~FGGlobals() { // save user settings (unless already saved) saveUserSettings(); @@ -197,7 +207,7 @@ FGGlobals::~FGGlobals() // Shutdown that implicitly assume that other subsystems // are still operational (Due to the dynamic allocation and // deallocation of AIModel objects. To ensure we can safely - // shut down all subsystems, make sure we take down the + // shut down all subsystems, make sure we take down the // AIModels system first. SGSubsystemRef ai = subsystem_mgr->get_subsystem("ai-model"); if (ai) { @@ -205,9 +215,9 @@ FGGlobals::~FGGlobals() ai->unbind(); ai.clear(); // ensure AI is deleted now, not at end of this method } - + subsystem_mgr->shutdown(); - subsystem_mgr->unbind(); + subsystem_mgr->unbind(); subsystem_mgr->remove("aircraft-model"); subsystem_mgr->remove("tile-manager"); @@ -222,21 +232,21 @@ FGGlobals::~FGGlobals() // GraphicsContext) vw->stopThreading(); } - + // don't cancel the pager until after shutdown, since AIModels (and // potentially others) can queue delete requests on the pager. if (vw && vw->getDatabasePager()) { vw->getDatabasePager()->cancel(); vw->getDatabasePager()->clear(); } - + osgDB::Registry::instance()->clearObjectCache(); - + // renderer touches subsystems during its destruction set_renderer(NULL); _scenery.clear(); _chatter_queue.clear(); - + delete subsystem_mgr; subsystem_mgr = NULL; // important so ::get_subsystem returns NULL vw = 0; // don't delete the viewer until now @@ -251,14 +261,14 @@ FGGlobals::~FGGlobals() simgear::PropertyObjectBase::setDefaultRoot(NULL); simgear::SGModelLib::resetPropertyRoot(); - + delete locale; locale = NULL; - + cleanupListeners(); - + props.clear(); - + delete commands; } @@ -285,8 +295,8 @@ void FGGlobals::set_fg_root (const std::string &root) { n = n->getChild("fg-root", 0, true); n->setStringValue(fg_root.c_str()); n->setAttribute(SGPropertyNode::WRITE, false); - - simgear::ResourceManager::instance()->addBasePath(fg_root, + + simgear::ResourceManager::instance()->addBasePath(fg_root, simgear::ResourceManager::PRIORITY_DEFAULT); } @@ -321,7 +331,7 @@ void FGGlobals::append_data_path(const SGPath& path) if (!path.exists()) { SG_LOG(SG_GENERAL, SG_WARN, "adding non-existant data path:" << path); } - + additional_data_paths.push_back(path); } @@ -333,13 +343,13 @@ SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const return p; } } - + SGPath rootPath(fg_root); rootPath.append(pathSuffix); if (rootPath.exists()) { return rootPath; } - + SG_LOG(SG_GENERAL, SG_WARN, "dir not found in any data path:" << pathSuffix); return SGPath(); } @@ -351,9 +361,9 @@ void FGGlobals::append_fg_scenery (const std::string &paths) // find first unused fg-scenery property in /sim int propIndex = 0; while (sim->getChild("fg-scenery", propIndex) != NULL) { - ++propIndex; + ++propIndex; } - + BOOST_FOREACH(const SGPath& path, sgPathSplit( paths )) { SGPath abspath(path.realpath()); if (!abspath.exists()) { @@ -367,35 +377,35 @@ void FGGlobals::append_fg_scenery (const std::string &paths) SG_LOG(SG_GENERAL, SG_INFO, "skipping duplicate add of scenery path:" << abspath.str()); continue; } - + simgear::Dir dir(abspath); SGPath terrainDir(dir.file("Terrain")); SGPath objectsDir(dir.file("Objects")); - - // this code used to add *either* the base dir, OR add the + + // this code used to add *either* the base dir, OR add the // Terrain and Objects subdirs, but the conditional logic was commented // out, such that all three dirs are added. Unfortunately there's // no information as to why the change was made. fg_scenery.push_back(abspath.str()); - + if (terrainDir.exists()) { fg_scenery.push_back(terrainDir.str()); } - + if (objectsDir.exists()) { fg_scenery.push_back(objectsDir.str()); } - + // insert a marker for FGTileEntry::load(), so that // FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "", // "B/Terrain", "B/Objects", ""] fg_scenery.push_back(""); - + // make scenery dirs available to Nasal SGPropertyNode* n = sim->getChild("fg-scenery", propIndex++, true); n->setStringValue(abspath.str()); n->setAttribute(SGPropertyNode::WRITE, false); - + // temporary fix so these values survive reset n->setAttribute(SGPropertyNode::PRESERVE, true); } // of path list iteration @@ -481,7 +491,7 @@ void FGGlobals::set_renderer(FGRenderer *render) if (render == renderer) { return; } - + delete renderer; renderer = render; } @@ -498,7 +508,7 @@ FGGlobals::get_subsystem (const char * name) if (!subsystem_mgr) { return NULL; } - + return subsystem_mgr->get_subsystem(name); } @@ -568,7 +578,7 @@ static void treeDumpRefCounts(int depth, SGPropertyNode* nd) if (SGReferenced::count(cp) > 1) { SG_LOG(SG_GENERAL, SG_INFO, "\t" << cp->getPath() << " refcount:" << SGReferenced::count(cp)); } - + treeDumpRefCounts(depth + 1, cp); } } @@ -578,7 +588,7 @@ static void treeClearAliases(SGPropertyNode* nd) if (nd->isAlias()) { nd->unalias(); } - + for (int i=0; inChildren(); ++i) { SGPropertyNode* cp = nd->getChild(i); treeClearAliases(cp); @@ -589,9 +599,9 @@ void FGGlobals::resetPropertyRoot() { delete locale; - + cleanupListeners(); - + // we don't strictly need to clear these (they will be reset when we // initProperties again), but trying to reduce false-positives when dumping // ref-counts. @@ -604,19 +614,19 @@ FGGlobals::resetPropertyRoot() orientPitch.clear(); orientHeading.clear(); orientRoll.clear(); - + // clear aliases so ref-counts are accurate when dumped treeClearAliases(props); - + SG_LOG(SG_GENERAL, SG_INFO, "root props refcount:" << props.getNumRefs()); treeDumpRefCounts(0, props); //BaseStackSnapshot::dumpAll(std::cout); - + props = new SGPropertyNode; initProperties(); locale = new FGLocale(props); - + // remove /sim/fg-root before writing to prevent hijacking SGPropertyNode *n = props->getNode("/sim", true); n->removeChild("fg-root", 0); @@ -632,7 +642,7 @@ static std::string autosaveName() if (versionParts.size() < 2) { return "autosave.xml"; } - + os << "autosave_" << versionParts[0] << "_" << versionParts[1] << ".xml"; return os.str(); } diff --git a/src/Systems/electrical.cxx b/src/Systems/electrical.cxx index ebe684cc9..379841f5a 100644 --- a/src/Systems/electrical.cxx +++ b/src/Systems/electrical.cxx @@ -375,11 +375,12 @@ void FGElectricalSystem::init () { if ( path.length() ) { SGPath config = globals->resolve_aircraft_path(path); - +#if defined(ENABLE_DEV_WARNINGS) // load an obsolete xml configuration SG_LOG( SG_SYSTEMS, SG_WARN, "Reading deprecated xml electrical system model from\n " << config.str() ); +#endif try { readProperties( config.str(), config_props );