Question

I'm on Delphi 2009, and my application contains a data module, which has a custom component named 'Globals' on it.

In another form in the application, I'm trying to change a published property (a string) on the Globals component:

  dm.Globals.qhProject := _ProjectName.Text; //always gives access violation

The _ProjectName control is a TLabeledEdit descendant. I always get an access violation here if there's any text in the box.

However, if I manually assing a string to the property, I don't get the AV:

  dm.Globals.qhProject := 'some text'; //works

Here's the declaration of the qhProject property:

FqhProject: string;    
property qhProject: string read FqhProject write FqhProject;

I can't figure out why there's an AV here at all. I've tried moving the auto create order of the forms/data module around, but I always get the AV.

What am I doing wrong here?

Update:

I'm using Billenium Effects TFormContainer to switch between different forms in the application. Both forms that are involved here are in the form container. One form, TdlgSummary, contains the following:

procedure TdlgSummary.SyncVars;
begin
    dm.Globals.qhProject := _ProjectName.Text
end;

The other form, TdlgFinalize, contains the following:

dlgSummary.SyncVars;

If I run SyncVars inside of dlgSummary, it works fine. If I call it from dlgFinalize, I get the AV. This seems to be the crux of the problem, but I can't figure out what's going wrong. Even if I switch control to dlgFinalize, dlgSummary hasn't been destroyed, because I can go back to it. Any ideas?

Was it helpful?

Solution

Looks to me like _ProjectName is nil. Try putting a breakpoint at this line and examine _ProjectName, see if it gives a valid reference or not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top