TObjectList sort throwing an Access Violation after running

Hi,

I have been trying to get my custom sort routine to run on my TObjectList that contains a custom object of a TProvider. I did some looking around on the internet about how to do my own custom sort and found a post on [stackoverflow|http://stackoverflow.com/questions/4784306/delphi-trouble-sorting-a-tobjectlist].

However when I write my code as follows

{code}
// Creating my TObject list of TProviders
Result          := TObjectList<TProvider>.Create(False);

// Populating my object list with values from my unordered dictionary
for MyProvider in FDictionary.Values do
  Result.Add(MyProvider);

// Trying to sort the objects in the object list
Result.Sort(TComparer<TProvider>.construct(
      function (const AProvider1, AProvider2 : TProvider) : Integer
      begin
        if AProvider1.AppointmentOrder > AProvider2.AppointmentOrder then
          Result := 1
        else
          Result := -1;
      end
  ));
{code}

and run it I receive the following Debugger Fault Notification:

Project {MyProject Path} faulted with message 'access violation at 0x0042aee3: write of address 0x000904d0.' Process Stopped. Use Step or Run to continue.

and when hit step or run in the IDE it throws the exact same error again and again. Is there something I am doing wrong here or should be doing differently with the sort?

Thanks in advance for the help
0
Steven
3/12/2013 11:18:45 PM
embarcadero.delphi.general 4258 articles. 0 followers. Follow

2 Replies
714 Views

Similar Articles

[PageSpeed] 28

Steven wrote:

> However when I write my code as follows
<snip>
> and run it I receive the following Debugger Fault Notification:

The code you have shown works perfectly fine for me when I run it as-is, 
so the problem has to be elsewhere.  My guess would be that the TProvider 
objects in your Dictionary are not being managed correctly, and most likely 
being freed outside of your TObjectList code.

--
Remy Lebeau (TeamB)
0
Remy
3/12/2013 11:46:54 PM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Steven wrote:
> 
> > However when I write my code as follows
> <snip>
> > and run it I receive the following Debugger Fault Notification:
> 
> The code you have shown works perfectly fine for me when I run it as-is, 
> so the problem has to be elsewhere.  My guess would be that the TProvider 
> objects in your Dictionary are not being managed correctly, and most likely 
> being freed outside of your TObjectList code.
> 
> --
> Remy Lebeau (TeamB)

Thanks for that Remy. I found the issue where the dictionary had items being freed when they should not have been.
0
Steven
3/14/2013 5:08:03 PM
Reply:

Similar Artilces:

Access violation running in Delphi 7
I accidentally ran out of memory (virtual and otherwise) while compiling a large project using Delphi 7 (had lots of applications running and compiled a large resource file into the project). I got a blank message at the time and Windows warned me in the system tray that Windows had run out of memory. I closed down Delphi and all my applications, then restarted Delphi 7. It compiled the project fine, but now whenever I try and run it from the IDE I get this message: Access violation at address 001525B8. Read of address 00130000. I've tried running the application outs...

Access Violation when running Delphi 7 App
I have compiled and succesfully run a Delphi 7 application on a Windows XP, Pentium 4 machine and a Windows 7, 64-bit, Dual core machine. When I try to run it on a Core i5 laptop running Windows 7, I get the following error when starting the application: Exception EAccessViolation in module "app name". Access violation at address 0. Read of address 0. Can anyone explain why this sort of thing happens? I have figured out what the problem is. The application tries to load a DLL dynamically when it runs and that DLL was missing. Pier "Pier Nardin" <p...

Delphi BDE
I (still) support two well established Delphi apps requiring BDE (Paradox tables). Suddenly they have started generating a consistent Access Violation (in Win XP) when starting to run in the IDE. The apps compile OK and the resulting exes run without complaint outside the IDE.It's not just my apps - the demo Fishfact and other demos generate an access violation as well as they start to run (after compiling OK). I have made no changes for a long time to the VCL etc. This happens in Delphi 4 and Delphi 7. I have tried re-installing Delphi and BDE and doing a system restore. The access vio...

Access Violation When Starting Delphi
Irregularly, when starting the D7 IDE with still nothing but the D7 splash screen showing, I get 'Access Violation in vcl70.bpl' followed by the message 'Error reading EditWindow.Icon.Data. The window does not have scroll bars.' At the moment, I am working on a single project so always open the same one. I have zero 3rd party components registered in D7. What to make out of this? Thank you for your comments. Andreas Hi! Try starting your project with -np switch. Delphi will open with no project. > Vincent Bergeron wrote: > Try starting your project...

Delphi 2010 Access Violation
I have an application developed with delphi 2010 professional. Are there any tools in the IDE that will help me find an access violation that shows up, when the application closes? I have steppd through the code,but can' t locate anything. I am not for sure but I think a form may not be destroyed. TIA Jan B wrote: > I have an application developed with delphi 2010 professional. Are > there any tools in the IDE that will help me find an access violation > that shows up, when the application closes? I have steppd through > the code,but can' t locate anything. ...

dynamic_cast throws access violation
Hi! Can anybody please tell me why I get an access violation when trying to do an up-cast using dynamic_cast<>(). Here is the code: (1) I have a TFRame that implements an interface called c_TestEnvironmentLogViewUpdateIfc class TTestEnvironmentLogViewFrame : public TFrame ,public c_TestEnvironmentLogViewUpdateIfc // act as view update for controller { __published: // IDE-managed Components .... } Where: /** * Interface to be implemented by a Test Environment Log View */ class c_TestEnvironmentLogViewUpdateIfc : public c_MVCViewIfc { public: ... } ...

Access Violation shows up in run but not in debug
I am running D2006. I have an access violation that shows up when I run my app, but when I step through in the debugger, there is no AV. I am using Dynamic Arrays that have worked OK in the past and when I watch the variables they look OK. Any suggestions for locating this Roach? Alan Jordan wrote: > I am running D2006. > > I have an access violation that shows up when I run my app, but when > I step through in the debugger, there is no AV. I am using Dynamic > Arrays that have worked OK in the past and when I watch the variables > they look OK. Any suggesti...

strange access violation when throwing Exception
Hi! I have a strange problema that cannot solve: I have this code : /***/ void DB::execQuery(AnsiString query, Classes::TComponent* AOwner) { TConsulta* q = new TConsulta (AOwner); q->SQLConnection = db(); q->SQL->Clear(); q->SQL->Add(query); try { try { q->ExecSQL(); } catch (const Exception &e) { if (log) { log->Add(e.Message); log->Add(query); } throw; } } __finally { delete q; } } /***/ It's part of a wrapper where I implement sql queries according to the driver used (dbExpress in this...

Create clientdataset access violation in Delphi XE6
I have Delphi XE6 running on a Windows 7 64 bt computer and am experiencing problems with clientdatasets which are independent of datasetproviders. Prior to moving to this computer from XE2, I just needed to right click the clientdataset and select "Create dataset" to create a version of the clientdataset ready for use. Now I get an access violation error in the IDE. I have midaslib included in my uses clause so it can't be that. Any suggestions? What has changed from XE2 to XE6 that is not obvious? Thanks Bruce Your Midaslib into the uses clause is not help...

Access Violations when 'Throwing' an exception
To All, Background - We are in the process of migrating from C++ CodeGear 2007 to C++ Embarcadero 2010. Our application(s) utilize 'throwing' exceptions for our validation, error handling and etc. Scenario - When our applications start we load a DLL (ensure appis registered, to login to DB, setup some settings, etc.) to do some housekeeping and then the application unloads the DLL. When our apps validate user inputs, etc. and they fail we throw an 'exception' and display to the user. Problem - When we do this, an 'access violation' etc. While trying to fi...

Access 2007 throw DAO in Delphi 2007
Hello, I have a such problem: In MS Access 2007 Microsoft added new field type "Attachment", it's a complex type which contains filename, filedata and others... I need to get list of these values to edit it. According to MSDN I tried to do like this in Delphi 2007: +procedure TForm1.Button1Click(Sender: TObject);+ +var+ +DAO: _DBEngine;+ +db: Database;+ +MyTable: DAO_TLB.Recordset2;+ +ClassID: TGUID;+ +V120: string;+ +oldPass, newPass: string;+ +DatabaseName : string;+ +TableName : string;+ +filename : string;+ +Fields : DAO_TLB.Fields;+ +attachments :...

Access violation on delphi XE6 (Windows 7)
Hello, After compiling my project i'm trying to run the program on DELPHI XE6 (windows 7) and get this error : First chance exception at $7620C42D. Exception class EAccessViolation with message 'Access violation at address 6FDD19D5 in module 'gdiplus.dll'. Read of address 40140603'. Process Pentagon.exe (6760) Can you please let me know how to fix this error ? Thanks, Shay. El 26/01/2015 a las 15:06, Shay Gibly escribió: > Hello, > > After compiling my project i'm trying to run the program on DELPHI XE6 (windows 7) and get this error : ...

Access Violation in TApplication.DoActionIdle in Delphi 2009
Anybody know if there already is a QC for this? The VCL code below very often gets an AV at the "UpdateActions" line: procedure TApplication.DoActionIdle; var I: Integer; begin for I := 0 to Screen.CustomFormCount - 1 do with Screen.CustomForms[I] do if HandleAllocated and IsWindowVisible(Handle) and IsWindowEnabled(Handle) then UpdateActions; end; John Jacobson wrote: > Anybody know if there already is a QC for this? No, there isn't. > The VCL code below very often gets an AV at the > "UpdateActions" lin...

InplaceMemo causes access violation in Delphi 2010
Hi there, the following problem occured with D2010 (the same code in D2007 is still in use an working well): in a component I use a TForm with a TMemo as an inplace editor. Everytime I try access propertys of the Memo I'll get an access violation Here's the code FMemoPopup:= TFInplaceMemo.Create(self); FMemoPopup.Parent:=nil; FMemoPopup.Visible:= false; //FMemoPopup.Memo1.Align:= alClient; //FMemoPopup.Memo1.OnKeyUp:= Memo_KeyUp; //FMemoPopup.Memo1.OnDblClick:= Memo_DblClick; Every of the 3 lines that are now commented cause the violation when uncommented. The TFIn...

Web resources about - TObjectList sort throwing an Access Violation after running - embarcadero.delphi.general

Resources last updated: 12/16/2015 9:42:31 AM