22 views
in GUI Development by
I have created a class Settings and its AutoObject GlobalSettings (referred the documentation  used ctrl Alt drag and drop to create the GlobalSettings) .I have some variables inside Settings like  Firstname which have some default value "Kumar". I was able to use it between two pages (Core::Group) like  Application::GlobalSettings.Firstname.

But the value set in one page doesn't persist between screen switches (SwitchToDialog ( new Application::screen1) ).

To test I have overridden Settings class method  'Init' and added trace " Settings init" and I can  see this trace printed multiple times .I am expecting only one Settings ::init across the Application .Is there any thing that I am missing. Can you please comment ?

1 Answer

+1 vote
by
 
Best answer

Hello,

according to your description, the global settings class is handled as an autoobject in order to have one global instance. This is very convenient, because autoobjects can be accessed from everywhere in your project.

Please consider the livetime of autoobjects. Everytime, the autoobject is no more in use, the instance will be deleted by the Garbage Collector. In order to prevent the Garbage Collector from freeing an autoobject, please add a variable to the root class, set the type to your class Application::Settings and the value to the instance (autoobject) of the class (Application::GlobalSettings). 

I hope this helps....

Best regards,

Manfred.

by
Hi Manfred,

Thanks, It worked.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...