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
0005096 [JEDI VCL] 00 JVCL Components major random 2010-01-06 17:02 2011-06-10 16:10
Reporter migajek View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.39
Summary 0005096: JvDocking: A component named TJvDockTabHostForm_<Form1>_<Form2>_7FEFA350 already exists
Description I 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 Information Exception 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)

Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0017079)
migajek (reporter)
2010-01-06 17:18

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);
(0017081)
migajek (reporter)
2010-01-06 17:38

ok it doesn't make sense as I can see ... changing the name cause the options not to be applied again, on loading...
(0017082)
migajek (reporter)
2010-01-07 00:18

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 }
(0017086)
jfudickar (developer)
2010-01-09 11:05

To get a unique name we can use the "CreateUniqueName" function from JvJvclUtils.
Is this a possible solution?
(0017087)
migajek (reporter)
2010-01-10 00:36

@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.
(0017114)
obones (administrator)
2010-01-13 17:04

Can you try with the latest SVN content and let us know how it goes?
(0017118)
migajek (reporter)
2010-01-13 21:01

it seems to be fixed now. At least it doesn't crash when testing it the same way as previously.
(0017458)
obones (administrator)
2010-06-07 13:52

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


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