User Tools

Site Tools


Callback - Element Destroyed

Summary

The script on this page is included by a script embedded within, and executed by, a DzCallBack that is connected to the destroyed(QObject*) signal on a given (predefined) DzElement. Several variables used in this script are assumed to be defined in the script that includes this script.

The purpose of this script is to find a list of callbacks, by name, and delete them when the element is deleted; to clean up after itself and avoid contributing to pollution of the callback stack.

See Also: Element Post-Load Create Callbacks

API Areas of Interest

Example

Callback_destroyed.dsa
// Define an anonymous function;
// limits the scope of variables
(function(){
 
	// 'CallBack' is a global transient variable, available when
	// this script is executed by a DzCallBack
 
	// If we did not find the 'CallBack' global transient;
	// this script was executed outside the context of a DzCallBack	
	if( typeof( CallBack ) == "undefined" ){
		// We are done...
		return;
	}
 
	// sCallBackGroup and aCallBackNames are assumed to be defined
	// in the script that includes this script; i.e., the CallBack
	// created in Callbacks_Element_Post_Load_Create.ds*
 
	// Get the callback manager
	var oCallBackMgr = App.getCallBackMgr();
 
	// Declare working variable
	var sCallBack;
 
	// Iterate over the callback names
	for( var i = 0, nCallBacks = aCallBackNames.length; i < nCallBacks; i += 1 ){
		// Get the 'current' callback name
		sCallBack = aCallBackNames[ i ];
		// Remove the callback
		oCallBackMgr.deleteCallBack( sCallBack );
	}
 
// Finalize the function and invoke
})();