Add checking that ViewModel and DataSets are assigned.

This commit is contained in:
Conrad Vermeulen 2024-01-02 10:38:19 +00:00
parent 17e44b0f97
commit bf9d496375

View File

@ -106,13 +106,19 @@ begin
LViewEngine := AObj.AsType<TMVCBaseViewEngine>;
LKey := AsString(ADeref, AContext);
// check if the key exists in the ViewModel
AFound := LViewEngine.ViewModel.TryGetValue(LKey, result);
if AFound then
exit;
if assigned(LViewEngine.ViewModel) then
begin
AFound := LViewEngine.ViewModel.TryGetValue(LKey, result);
if AFound then
exit;
end;
// check if we have a dataset
AFound := LViewEngine.ViewDataSets.TryGetValue(LKey, LDataSet);
if AFound then
exit(LDataSet);
if assigned(LViewEngine.ViewDataSets) then
begin
AFound := LViewEngine.ViewDataSets.TryGetValue(LKey, LDataSet);
if AFound then
exit(LDataSet);
end;
// we don't know anything about the key, so behave accordingly
if ARaiseIfMissing then
RaiseError(APosition, SCannotDereferenceValueOnObject, [LKey, SDictionary]);