Fixed segfault in light manager

Also fixed minor memory leak
dev-ui
Piotr Dziwinski 2013-02-28 22:56:44 +01:00
parent 08c646bb92
commit f729686539
2 changed files with 10 additions and 4 deletions

View File

@ -389,7 +389,8 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type)
m_lightMap[i] = -1; m_lightMap[i] = -1;
std::vector<DynamicLight> sortedLights = m_dynLights; std::vector<DynamicLight> sortedLights = m_dynLights;
std::sort(sortedLights.begin(), sortedLights.end(), LightsComparator(m_engine->GetEyePt(), type)); LightsComparator lightsComparator(m_engine->GetEyePt(), type);
std::sort(sortedLights.begin(), sortedLights.end(), lightsComparator);
int lightMapIndex = 0; int lightMapIndex = 0;
for (int i = 0; i < static_cast<int>( sortedLights.size() ); i++) for (int i = 0; i < static_cast<int>( sortedLights.size() ); i++)
@ -460,7 +461,7 @@ bool CLightManager::LightsComparator::operator()(const DynamicLight& left, const
float leftWeight = GetLightWeight(left); float leftWeight = GetLightWeight(left);
float rightWeight = GetLightWeight(right); float rightWeight = GetLightWeight(right);
return leftWeight <= rightWeight; return leftWeight < rightWeight;
} }
} // namespace Gfx } // namespace Gfx

View File

@ -3833,7 +3833,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
int rankObj = 0; int rankObj = 0;
int rankGadget = 0; int rankGadget = 0;
CObject* sel = 0; CObject* sel = 0;
std::string oldLocale;
char *locale = setlocale(LC_NUMERIC, nullptr); char *locale = setlocale(LC_NUMERIC, nullptr);
if (locale != nullptr)
oldLocale = locale;
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
while (fgets(line, 500, file) != NULL) while (fgets(line, 500, file) != NULL)
@ -4568,8 +4573,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
} }
m_dialog->SetSceneRead(""); m_dialog->SetSceneRead("");
m_dialog->SetStackRead(""); m_dialog->SetStackRead("");
setlocale(LC_NUMERIC, locale); setlocale(LC_NUMERIC, oldLocale.c_str());
} }
//! Creates an object of decoration mobile or stationary //! Creates an object of decoration mobile or stationary