SRL Archive - Bugs

GetMenuText temporary fix...


mormonman

2010-12-07 02:00:10

Test this please.

{*******************************************************************************
function GetMenuText: TStringArray;
By: BenLand100
Description: Dumps the data from the MenuNodeList into a TStringArray
*******************************************************************************}
function GetMenuText: TStringArray;
var
count, nodeList, head, next, last, javaString: Integer;
item: string;
begin
try
nodeList:= SmartGetFieldObject(0, hook_static_MenuNodeList);
head:= SmartGetFieldObject(nodeList, hook_nodelist_Head);
//for some reason, the head has null strings, so skip it
next:= SmartGetFieldObject(head, hook_node_Next);
count:= GetMenuCount;
SetLength(result,count);
repeat
javaString:= SmartGetFieldObject(next, hook_menu_Action);
item:= GetJavaString(javaString,256);
SmartFreeObject(javaString);
javaString:= SmartGetFieldObject(next, hook_menu_Option);
item:= item + ' ' + GetJavaString(javaString,256);
SmartFreeObject(javaString);
result[count-1]:= TrimHTML(item);
last:= next;
next:= SmartGetFieldObject(last, hook_node_Next);
SmartFreeObject(last);
count:= count - 1;
until (count = 0);
finally
SmartFreeObject(next);
SmartFreeObject(head);
SmartFreeObject(nodeList);
end;
end;

lordsaturn

2010-12-07 08:49:15

Doesn't work. Because the error occurs inside SMART and not simba.

Maybe it could be fixed by
head:= SmartGetFieldObject(nodeList, hook_nodelist_Head);
if head = null then Exit;
//for some reason, the head has null strings, so skip it
next:= SmartGetFieldObject(head, hook_node_Next);
if that's what is causing the error.

mormonman

2010-12-07 13:43:25

From: lordsaturn
Doesn't work. Because the error occurs inside SMART and not simba.

Maybe it could be fixed by
head:= SmartGetFieldObject(nodeList, hook_nodelist_Head);
if head = null then Exit;
//for some reason, the head has null strings, so skip it
next:= SmartGetFieldObject(head, hook_node_Next);
if that's what is causing the error.


Would you have to use the "SmartIsNull();"?

lordsaturn

2010-12-07 14:05:17

From: mormonman
Would you have to use the "SmartIsNull();"?


I was typing in pseudocode. If that's what works then yes.

Method

2010-12-07 14:33:45

The head of a list in the client should never be null.

mormonman

2010-12-07 14:42:37

From: Method
The head of a list in the client should never be null.


Just like the renderdata and render should never return null but sometimes they do.

Method

2010-12-07 14:52:51

From: mormonman
Just like the renderdata and render should never return null but sometimes they do.


Are you referring to a situation where you access the list and it's no longer valid when you're trying to use it or something silly that SMART does for some odd reason? The head pointer should never be null like the "render" and "renderdata" objects can be, presumably when the client switches toolkits or viewports.

mormonman

2010-12-07 17:37:02

From: Method
Are you referring to a situation where you access the list and it's no longer valid when you're trying to use it or something silly that SMART does for some odd reason? The head pointer should never be null like the "render" and "renderdata" objects can be, presumably when the client switches toolkits or viewports.


Ok, so the real problem with the function is that it sometimes throws an "out of range" exception.