Jump to content
Tim Koscielski

Issue with DEVELOPMENT-branch (was BETA) building APP

Recommended Posts

In the previous BETA channel, I had an app that was working just fine. Now in version 3.1.0.88, the app build creates an error when run.

"TypeError, Cannot read property 'FHandle$4' of null"

I know this is a BETA, but since it was working in the previous versions and then broke it this one, I'm wondering how I can go about figuring out what might have happened.

Just looking for any suggestions to investigate further.

Thanks.

 

 

Share this post


Link to post
Share on other sites

OK, now I have some more info. The issue I'm having is specifically with TW3Grid. My code was initially based on the demo provided and does approximately the exact same process. The demo grid project still works exactly as it is, but now I am comparing the two and at the moment everything seems to be reasonably the same

In ObjectInitialize in my project, I am creating the columns in the grid with the following code. The very first TW3TextColumn.Create I call is generating the error. I am digging into this later today and I'll continue to update what I find.

If anyone has any ideas, please let me know.
 

procedure TForm.InitGrid;
var
	Col_ProjectId: TW3TextColumn;

begin
    Col_ProjectId := nil;

    Col_ProjectId := TW3TextColumn.Create(W3Grid1 as IW3ColumnsControl);
    
    Col_ProjectId.Header.Caption := '#';
    Col_ProjectId.Header.Alignment := taCenter;
    Col_ProjectId.Alignment := taCenter;
    Col_ProjectId.Width := 100;

    W3Grid1.Columns.Add(Col_ProjectId);

end;

 

Share this post


Link to post
Share on other sites

This works for me just fine.  Not sure where you are calling InitGrid from

 

procedure TForm1.W3Button1Click(Sender: TObject);
var
    Col_ProjectId: TW3TextColumn;
begin
    Col_ProjectId := TW3TextColumn.Create(W3Grid1 as IW3ColumnsControl);
    Col_ProjectId.Header.Caption := '#';
    Col_ProjectId.Header.Alignment:= taCenter;
    Col_ProjectId.Alignment := taCenter;
    Col_ProjectId.Width:= 100;
    W3Grid1.Columns.Add(Col_ProjectId);
end;

Share this post


Link to post
Share on other sites

so does this:

procedure TForm1.InitGrid;
var
    Col_ProjectId: TW3TextColumn;
begin
    Col_ProjectId := TW3TextColumn.Create(W3Grid1 as IW3ColumnsControl);
    Col_ProjectId.Header.Caption := '#';
    Col_ProjectId.Header.Alignment:= taCenter;
    Col_ProjectId.Alignment := taCenter;
    Col_ProjectId.Width:= 100;
    W3Grid1.Columns.Add(Col_ProjectId);
end;


procedure TForm1.InitializeObject;
begin
  inherited;
  {$I 'Form1:impl'}
   InitGrid;
end;

 

Share this post


Link to post
Share on other sites

Ok, I think I need to go back on all of that above, it was NOT A PROBLEM with the Grid. I think it was a problem with object initialization. In this project, I was using FontAwesome and I had the following for a form in the InitializeObject procedure. I initialized the Grid and added the InnerHTML to a button.

procedure TForm_ProjectMasterListN.InitializeObject;
begin
  inherited;
  {$I 'Form_ProjectMasterListN:impl'}

  writeln('InitializeObject');
  InitGrid;
  W3Button1.InnerHTML:=#'<i class="fa fa-refresh fa-2x"></i>';

end;

As I worked through this I discovered the when I removed InitGrid and the InnerHTML items from InitializeObject, the error went away. I then added these to InitializeForm and it then worked correctly. I am assuming that with some of the new features in this BETA, this is something changed, but also I assume that I had been doing this the wrong way anyway.

Now when I run my code in InitializeForm, it all works. If anyone has any additional insight, please let me know.

Thank you for the help.

Share this post


Link to post
Share on other sites
7 hours ago, IElite said:

so does this:


procedure TForm1.InitGrid;
var
    Col_ProjectId: TW3TextColumn;
begin
    Col_ProjectId := TW3TextColumn.Create(W3Grid1 as IW3ColumnsControl);
    Col_ProjectId.Header.Caption := '#';
    Col_ProjectId.Header.Alignment:= taCenter;
    Col_ProjectId.Alignment := taCenter;
    Col_ProjectId.Width:= 100;
    W3Grid1.Columns.Add(Col_ProjectId);
end;


procedure TForm1.InitializeObject;
begin
  inherited;
  {$I 'Form1:impl'}
   InitGrid;
end;

  Which version of SMS are you running? In my version, I can't do this in InitializeObject, but I can get it to work in InitializeForm.

 

Share this post


Link to post
Share on other sites

@Tim Koscielski Here's my best guess about what is going on:

I assume you have added the Grid in the Designer. That means that the Grid control is created in Form.InitializeObject here:

{$I 'Form_ProjectMasterListN:impl'}

The compiler generates the code to create the grid and set its properties. After that you call InitGrid. Now, when a control is created in JavaScript, the browser initializes it asynchronously. This means that your code continues to run but it takes some time before the control is actually ready. It may be that on your computer it takes so long that the Grid's handle is not ready when you start accessing it.

In the latest development update I changed the code that is created for that impl section. When earlier the control was just created and properties were set, now the generated code waits for the object to be ready. Only after that it starts setting properties. It eliminates random problems.

To be sure that the Grid is ready, you can call InitGrid like this:

  TW3Dispatch.WaitFor([W3Grid1], procedure
    begin
      InitGrid;
    end);

That's the same way the code generated by the IDE does it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×