105 views
in GUI Development by
Good Afternoon Paul, Manfred and fellow developers,

I need to detect USB and open a popup. I have assigned attachobserver ;

attachobserver usb_in_status, ^Data::Display.usbAvailable; // this will set the flag .usbAvailable

if(Data::Display.usbAvailable == 0)
postsignal on_cancel;

and when the flag is set to 1,  the USB is detected and the Pop up opens up as desired. But when i remove the usb and put it back, it fails to detect the usb. But when i go to another window and come back to the home page, the usb is detected. Hence, I want to refresh my home screen(window). I tried with (1) reIntmethod, also (2) separate slot called by post signal in Init method.

The 2 mentioned approaches didnt work.

 

Thank you in advance.

Yours Sincerely,

Ashay

1 Answer

0 votes
by

Hello Ashay,

I assume the property that you are accessing from time to time is stored within a device class (your Data class). Typically, a device class is handled as an autoobject in order to have one global instance of the device class. This is very convenient, because autoobjects can be accessed from everywhere in your project.

Please consider the lifetime 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::Device and the value to the instance (autoobject) of the class. 

Does this answer your question?

Best regards,

Manfred.

by
Yes manfred. I added the variable in root class and also an observer to check the insertion of USB. Thank you so much!

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

...