Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005862 [JEDI VCL] 00 JVCL Components major always 2012-04-19 16:36 2013-12-13 11:29
Reporter RHoek View Status public  
Assigned To obones
Priority normal Resolution duplicate  
Status resolved   Product Version Daily / GIT
Summary 0005862: TJvInspectorClassItem.GetDisplayValue return value might be invalid (JvInspector)
Description The code uses a non-initialized return value in GetDisplayValue (depending the situation).... (See ***)

function TJvInspectorTStringsItem.GetDisplayValue: string;
var
  Obj: TObject;
begin
  Obj := TObject(Data.AsOrdinal);
  if not Multiline then
  begin
    // RH - 2012-04-19: Added initialisation of Result variable!
    Result := inherited GetDisplayValue;
    if Obj <> nil then
      Result := Result*** + '(' + Obj.ClassName + ')'
    else
      Result := Result*** + '(' + GetTypeData(Data.TypeInfo).ClassType.ClassName + ')';
  end
  else
    Result := TStrings(Obj).Text;
end;

*** return value has not yet been initialized
Additional Information NEW CODE:

function TJvInspectorTStringsItem.GetDisplayValue: string;
var
  Obj: TObject;
begin
  Obj := TObject(Data.AsOrdinal);
  if not Multiline then
  begin
    // RH - 2012-04-19: Added initialisation of Result variable!
    Result := inherited GetDisplayValue;
    if Obj <> nil then
      Result := Result + '(' + Obj.ClassName + ')'
    else
      Result := Result + '(' + GetTypeData(Data.TypeInfo).ClassType.ClassName + ')';
  end
  else
    Result := TStrings(Obj).Text;
end;
Tags No tags attached.
Attached Files

- Relationships
has duplicate 0005861resolvedobones TJvInspectorClassItem.GetDisplayValue return value might be invalid (JvInspector) 

-  Notes
(0019711)
RHoek (reporter)
2012-04-19 16:39

NOTE: this one is regarding "TJvInspectorTStringsItem.GetDisplayValue"

(not TJvInspectorClassItem.GetDisplayValue as the title suggests...)
(0019855)
obones (administrator)
2012-06-11 17:28

Please provide the zipped sources of a sample application showing this.
(0019919)
RHoek (reporter)
2012-06-12 15:36

I don't have a sample which 'shows' the problem, because I've never 'seen' it do something wrong.

I only know for sure, when you use an non-initialized variable (like Result) to set the same variable (or any other variable), you will get strange results at some point!
(0019927)
obones (administrator)
2012-06-12 16:19

Except that this is a string variable and I believe that variable to be initialized to an empty string.
(0019931)
RHoek (reporter)
2012-06-12 16:29

Hmmm, you're right - never thought of that.

But why the use the syntax 'Result := Result + Newdata;', when no initial data is available?

As far as I'm concerned there's no need to modify the code anymore, other then looking at it from a functional point of view...

- Issue History
Date Modified Username Field Change
2012-04-19 16:36 RHoek New Issue
2012-04-19 16:39 RHoek Note Added: 0019711
2012-06-11 17:28 obones Note Added: 0019855
2012-06-11 17:28 obones Status new => feedback
2012-06-12 15:36 RHoek Note Added: 0019919
2012-06-12 16:19 obones Note Added: 0019927
2012-06-12 16:29 RHoek Note Added: 0019931
2013-12-13 11:28 obones Relationship added has duplicate 0005861
2013-12-13 11:29 obones Status feedback => resolved
2013-12-13 11:29 obones Resolution open => duplicate
2013-12-13 11:29 obones Assigned To => obones


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker