Ultralabel disposed object  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Ultralabel disposed object

Postby Riyaz » Tue Nov 27, 2018 12:40 pm

Hi There

Am currently working on a plugin which adds a dropdown to the PO panel, all works fine the first time, but if you close and reopen the purchase order, it comes with the below exception,

Error: "Cannot access a disposed object"
Object Name: 'Ultralabel''
Module: 'CreateHandle'

Have attached the plugin, can you pls kindly advise
Attachments
Plugin - Purchase order - warehouse convert.xml
(39.27 KiB) Downloaded 67 times
Riyaz
Kohai
Kohai
 
Posts: 233
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Ultralabel disposed object  Topic is solved

Postby Mike.Sheen » Tue Nov 27, 2018 12:59 pm

This is caused by creating new controls and storing them as fields in the FormPlugin class.

The class is instantiated ONCE at login time, then the methods SetupBeforeHandlers and Setup are invoked when a form loads IF that form was added to the Forms tab of the plugin.

When creating controls and adding them to a form, they'll be destroyed when the form closes - but your fields in the FormPlugin still reference them.

The easiest way around this is to not have these controls as fields - create them in the Setup method and store them in the GenericObjectCollection of the form. When you want to access them, retrieve them from the GenericObjectCollection.

Your plugin modified to do this is attached.
Attachments
Plugin Purchase order - warehouse convert - Modified to use GenericObjectCollection.xml
(42.71 KiB) Downloaded 70 times
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 11 guests