View Issue Details

IDProjectCategoryView StatusLast Update
0005096JEDI VCL00 JVCL Componentspublic2011-06-10 16:10
ReportermigajekAssigned Toobones 
PrioritynormalSeveritymajorReproducibilityrandom
Status resolvedResolutionfixed 
Product Version3.39 
Target VersionFixed in Version3.40 
Summary0005096: JvDocking: A component named TJvDockTabHostForm_<Form1>_<Form2>_7FEFA350 already exists
DescriptionI have a code which automatically docks all the forms to bottom dock, as tabs (VS.net style) using ManualTabDock / ManualTabDockAddPage.
Later, LoadDockTreeFromFile is being executed.

Recently I got that error:

A component named TJvDockTabHostForm_FormDebuggerLocalVars_FormDebuggerGlobalVars_7FEFA350 already exists.



I believe it might be caused by creating the Tab host again (one was created by my "default positioning" code) while the second one is being created by LoadDockTreeFromFile function (the docks layout saved in file was the one generated by my "default positioning" function, since I haven't changed anything).
I was unable to reproduce the error, however I think it might appear randomly ...
is the text appended at the end of DockTabHostForm name some pointer to it?

Maybe it should be named randomly?

Stack trace included, however I don't think it helps here much...

migajek
Additional InformationException class: EComponentError

Exception message: A component named TJvDockTabHostForm_FormDebuggerLocalVars_FormDebuggerGlobalVars_7FEFA350 already exists.

Exception address: 4003BBBF

------------------------------------------------------------------------------

Stack list, generated 2010-01-06 16:42:29

(0003ABBA){rtl70.bpl } [4003BBBA] Classes.TComponent.ValidateRename

(0003ACA4){rtl70.bpl } [4003BCA4] Classes.TComponent.SetName

(0001E874){JvDockingD7R.bpl} [495BF874] JvDockControlForm.TJvDockClient.CreateTabHostAndDockControl (Line 2946, "" + 2)

TagsNo tags attached.

Activities

migajek

2010-01-06 17:18

reporter   ~0017079

It seems I have found out the solution which however might not be proper.

in TJvDockClient.CreateTabHostAndDockControl

I've changed the code so now the id is generated from getTickCount, not only the pointer.... it seems to be a workaround for my problem.

  Result.Name := 'TJvDockTabHostForm_' + Control1.Name + '_' + Control2.Name + '_' +
    IntToHex(Integer(Result)+getTickCount, 8);

migajek

2010-01-06 17:38

reporter   ~0017081

ok it doesn't make sense as I can see ... changing the name cause the options not to be applied again, on loading...

migajek

2010-01-07 00:18

reporter   ~0017082

I believe I found a better way this time ... here is my workaround.
it's not pretty, but this time it works (so far at least...)

I'm just checking if there is a form with such name, if so - I don't create it anymore, instead I use the one which exists currently ...

function TJvDockClient.CreateTabHostAndDockControl(Control1, Control2: TControl): TJvDockTabHostForm;
var
  Page: TJvDockTabPageControl;
  OldDockWidth, OldDockHeight: Integer;
  // migajek
  fFound: boolean;
  n: string;
  i: integer;
  // --
begin
  Result := TJvDockTabHostForm.Create(Application);
  // migajek
  fFound:= false;
  n:= 'TJvDockTabHostForm_' + Control1.Name + '_' + Control2.Name + '_' +
    IntToHex(Integer(Result), 8);
  for i:= 0 to application.ComponentCount - 1 do
    if (application.Components[i] is TJvDockTabHostForm) and (application.Components[i].name = n) then
      begin
        FreeAndNil(result);
        result:= TJvDockTabHostForm(application.Components[i]);
        fFound:= true;
        break;
      end;

  if not fFound then
    Result.Name:= n;

  { CreateTabDockClass implicitly sets Result.DockClient.DockStyle via the
    assign in that function }

jfudickar

2010-01-09 11:05

developer   ~0017086

To get a unique name we can use the "CreateUniqueName" function from JvJvclUtils.
Is this a possible solution?

migajek

2010-01-10 00:36

reporter   ~0017087

@jfudickar, I'm afraid it is not the solution.

as I mentioned in previous comment, using getTickCount() to generate name (which makes it unique, leaving so small chance to have a duplicate that it was ok for tests) had broken restoring proper position ...

I don't really get the JvDocking internals idea but I believe it is better to keep the current instance of tab host and return it if needed, just like in the code from my last comment.

obones

2010-01-13 17:04

administrator   ~0017114

Can you try with the latest SVN content and let us know how it goes?

migajek

2010-01-13 21:01

reporter   ~0017118

it seems to be fixed now. At least it doesn't crash when testing it the same way as previously.

obones

2010-06-07 13:52

administrator   ~0017458

Thanks for letting us know

Issue History

Date Modified Username Field Change
2010-01-06 17:02 migajek New Issue
2010-01-06 17:18 migajek Note Added: 0017079
2010-01-06 17:38 migajek Note Added: 0017081
2010-01-07 00:18 migajek Note Added: 0017082
2010-01-09 11:05 jfudickar Note Added: 0017086
2010-01-10 00:36 migajek Note Added: 0017087
2010-01-13 17:04 obones Note Added: 0017114
2010-01-13 17:04 obones Status new => feedback
2010-01-13 21:01 migajek Note Added: 0017118
2010-06-07 13:52 obones Note Added: 0017458
2010-06-07 13:52 obones Status feedback => resolved
2010-06-07 13:52 obones Fixed in Version => Daily / SVN
2010-06-07 13:52 obones Resolution open => fixed
2010-06-07 13:52 obones Assigned To => obones
2011-06-10 16:10 obones Fixed in Version Daily / SVN => 3.40