MeasureScript: Additional fix for r663.

This commit is contained in:
spx 2010-12-13 11:47:03 +00:00
parent cb839b7ce8
commit 8c169e4d21
2 changed files with 4 additions and 31 deletions

View File

@ -13,6 +13,8 @@ CMeasureScript::CMeasureScript(CMeterWindow* meterWindow) : CMeasure(meterWindow
{ {
LuaManager::Init(); LuaManager::Init();
m_pLuaScript = NULL;
m_bUpdateDefined = false; m_bUpdateDefined = false;
m_bGetValueDefined = false; m_bGetValueDefined = false;
m_bGetStringValueDefined = false; m_bGetStringValueDefined = false;
@ -88,37 +90,8 @@ const WCHAR* CMeasureScript::GetStringValue(bool autoScale, double scale, int de
return CheckSubstitute(m_strValue.c_str()); return CheckSubstitute(m_strValue.c_str());
} }
else
{
static WCHAR buffer[MAX_LINE_LENGTH];
static WCHAR buffer2[MAX_LINE_LENGTH];
double theValue = GetValue();
if(percentual) return CMeasure::GetStringValue(autoScale, scale, decimals, percentual);
{
swprintf(buffer, L"%i", (UINT)(100.0 * GetRelativeValue()));
}
else if(autoScale)
{
GetScaledValue(decimals, theValue, buffer);
}
else
{
if(decimals == 0)
{
double val = theValue * (1.0 / scale);
val = (val + ( (val >= 0) ? 0.5 : -0.5 ) );
swprintf(buffer, L"%lli", (LONGLONG)val);
}
else
{
swprintf(buffer2, L"%%.%if", decimals);
swprintf(buffer, buffer2, theValue * (1.0 / scale));
}
}
return CheckSubstitute(buffer);
}
} }
static void stackDump (lua_State *L) { static void stackDump (lua_State *L) {

View File

@ -60,7 +60,7 @@ LuaScript::LuaScript(lua_State* p_pState, const char* p_strFile, const char* p_s
LuaScript::~LuaScript(void) LuaScript::~LuaScript(void)
{ {
delete[] m_strTableName; if (m_strTableName) free(m_strTableName);
} }
void LuaScript::BindVariable(const char* p_strName, void* p_pValue, const char* p_strTypeName) void LuaScript::BindVariable(const char* p_strName, void* p_pValue, const char* p_strTypeName)