Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Bold/Persistence    [ Add a report in this area ]  
Report #:  4870   Status: Closed
Association Objects & UpdateDatabaseWithList exceptions
Project:  Delphi Build #:  4.0.0.21
Version:    7.0 Submitted By:   daniel mauric
Report Type:  Basic functionality failure Date Reported:  6/28/2003 6:06:00 PM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   194582
Resolution: Fixed (Resolution Comments) Resolved in Build: : 7.0.8.1
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 1
Description
When adding/removing objects to a multilink association objects are automatically created/deleted. But there seems to be something wrong with the way these are counted internally, as an UpdateDatabaseWithList raises an List index out of bounds in certain situations.

I really can't describe it better at this point. The attached app does show the problem clearly. I will update the description when I get a better idea of the cause of the problem.
Steps to Reproduce:
Run the attached app, create DB & open system.

1. Create a Person
2. Create a Group
3. Press the 'Clear & Add' button 5 times or type 5 in the edit box & press once
4. Delete the Person
5. Press the 'FormSaver Apply' button
6. 'List index out of bounds (3)'

Exception is raised in TBoldFormSaver.SaveObjects method, in a call to UpdateDatabaseWithList. A second call to UpdateDatabaseWithList completes without exceptions.

If UpdateDatabase is executed instead of UpdateDatabaseWithList everything works fine.

You can repeat the process with a different number in the edit box, observe the difference in the index in the exception. Here are some results, I can't recognize a pattern though.

5x = 3
10x = 4
20x = 7
30x = 9
40x = 12
50x = 14
Workarounds
A second call to UpdateDatabaseWithList suceeds, so here's a workaround:

A general case:

  try
    SystemHandle.system.UpdateDatabaseWithList(TempList);
  except
    on e: EListError do
        SystemHandle.system.UpdateDatabaseWithList(TempList)
    else
       raise;
  end;

TBoldFormSaver.SaveObjects :

    TempList := Objects.Clone as TBoldObjectList;
    try
      try
        SystemHandle.system.UpdateDatabaseWithList(TempList);
      except
        on e: EListError do
        try
          SystemHandle.system.UpdateDatabaseWithList(TempList);
        except
          on e: exception do
          begin
            if assigned(OnUpdateException) then
              OnUpdateException(e)
            else
              raise;
          end
        end;
      end;
    finally
      TempList.Free;
    end;
    Objects.Clear;
Attachment
UpdateDBWithList.zip
Comments

Inspiration Matters Ltd Director at 1/24/2004 6:37:06 AM -
I get the same error when deleting objects with cascade delete to other objects.  The ListIndexOutOfBounds happens on the next System.UpdateDatabase.  No need for UpdateDatabaseWithList to be involved.

Bryan

Kjell Rilbe at 2/21/2004 2:57:45 PM -
I can consistently reproduce this error but am unable to publish the application for business reasons as well as for practical ones. This is a BoldExpress setup running under IIS.

I might be able to isolate the problem with some work but have not time to do so right now. If anyone (Jesper?) needs help isolating the bug, please contact me and I'll see what I can do, or rather, what we can do together.

Server Response from: ETNACODE01