678 views
in Embedded Wizard Studio by

Hi,

I am developing a new GUI application targeting ESP32. 

When I was prototyping the app on embedded wizard, everything was fine. But when I downloaded it to the ESP32, it crash constantly.

Eventually, I found that it is because when I present a new dialog by using :

Owner.PresentDialog( new newscreen …

At the runtime, the Owner somehow is null, and cause the code to address the data around address 0, so that it crash. But when prototyping, the Owner was null when I instantiated it, but is changed somehow later, why it is different?

From the documentation, I know Owner will be set when Add() is invoked. Is there any other way will cause the Owner to be set? 

1 Answer

+1 vote
by
 
Best answer

Hello John,

first at all I would recommend the chapter Understand the view tree and the Owner relationships. According to the description found there, the Owner variable can be null when the corresponding view or GUI component does not belong to the view tree anymore. For example, a dialog after being dismissed, does not belong to the view tree. The corresponding object can still exist when there is a valid reference to the object. Its Owner variable however is null then.

In your concrete case I suppose some race condition case. Possibly the code Owner.PresentDialog() is executed in response to some event, timer expiration or it is delayed by a postsignal. In such case it is possible, that the corresponding GUI component is removed from the view tree shortly before the event/timer/signal is processed. You will need to adapt your code by additional if condition to test this situation. For example:

if ( Owner )
  Owner.PresentDialog( ... );

If your application is using consequently dialogs, better is to use the IsActiveDialog(), etc. methods to avoid the race conditions. Please see the section Identify the active Dialogs and avoid race conditions.

I hope it helps you further.

Best regards

Paul Banach

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...