LasDebuggerFp: Better error handling when trying to cast to instance class (show none casted class, if cast not avail)

git-svn-id: trunk@63398 -
This commit is contained in:
martin 2020-06-19 17:45:26 +00:00
parent be7b855369
commit 4b28988db2
2 changed files with 13 additions and 2 deletions

View File

@ -207,6 +207,7 @@ type
property ParentTypeInfo: TFpSymbol read GetParentTypeInfo; // For members, the class in which this member is declared
property LastError: TFpError read GetLastError;
procedure ResetError;
end;
{ TFpValueConstNumber }
@ -650,6 +651,11 @@ begin
Result := ti.GetInstanceClassName(Self, AClassName);
end;
procedure TFpValue.ResetError;
begin
FLastError := NoError;
end;
function TFpValue.GetTypeInfo: TFpSymbol;
begin
if (DbgSymbol <> nil) and (DbgSymbol.SymbolType = stValue) then

View File

@ -2419,7 +2419,8 @@ begin
exit;
end;
if (ResValue.Kind = skClass) and (ResValue.AsCardinal <> 0) and (defClassAutoCast in EvalFlags)
if (ResValue.Kind = skClass) and (ResValue.AsCardinal <> 0) and
(not IsError(ResValue.LastError)) and (defClassAutoCast in EvalFlags)
then begin
if ResValue.GetInstanceClassName(CastName) then begin
PasExpr2 := TFpPascalExpression.Create(CastName+'('+AExpression+')', AContext);
@ -2431,6 +2432,10 @@ begin
end
else
PasExpr2.Free;
end
else begin
ResValue.ResetError; // in case GetInstanceClassName did set an error
// TODO: indicate that typecasting to instance failed
end;
end;
@ -2441,7 +2446,7 @@ begin
Res := FPrettyPrinter.PrintValue(AResText, ATypeInfo, ResValue, DispFormat, RepeatCnt);
// PCHAR/String
if APasExpr.HasPCharIndexAccess then begin
if APasExpr.HasPCharIndexAccess and not IsError(ResValue.LastError) then begin
// TODO: Only dwarf 2
APasExpr.FixPCharIndexAccess := True;
APasExpr.ResetEvaluation;