Reference System Changes

SingleRefMaker can drop references automatically

SingleRefMaker now supports dropping its reference automatically when certain events occur. This reduces the potential for errors and eliminates the burden on developers to clean up references. This new behavior of SingleRefMaker instances is controlled by flags (set by the constructor or by SetAutoDropRefOnShutdown()) that can be set by the owner object. However, the default behavior is to maintain the reference on shutdown or plug-in unloading, unless the SingleRefMaker's owner explicitly instructs it to drop it when these events occur.

For more information see AutoDropRefOnShutdown in class SingleRefMaker in the C++ API Reference.

Changes to NotifyDependents() and NotifyRefChanged()

The signature of ReferenceMaker::NotifyDependents() was changed from:

virtual RefResult ReferenceMaker::NotifyDependents(
	Interval changeInt, 
	PartID partID, 
	RefMessage message, 
	SClass_ID sclass = NOTIFY_ALL,
	BOOL propagate = TRUE, 
	RefTargetHandle hTarg = NULL);

To:

virtual RefResult ReferenceMaker::NotifyDependents(
	const Interval& changeInt, 
	PartID partID, 
	RefMessage message, 
	SClass_ID sclass = NOTIFY_ALL,
 BOOL propagate = TRUE, 
	RefTargetHandle hTarg = NULL);

The signature of method ReferenceMaker::NotifyRefChanged() was changed from:

virtual RefResult ReferenceMaker::NotifyRefChanged(
	Interval changeInt, 
	RefTargetHandle hTarget, 
	PartID& partID,  
	RefMessage message) = 0;

To:

virtual RefResult ReferenceMaker::NotifyRefChanged(
	const Interval& changeInt, 
	RefTargetHandle hTarget, 
	PartID& partID,  
	RefMessage message, 
	BOOL propagate) = 0;

C++ and .NET plug-ins that implement or call the updated methods will need to be changed. A compiler error is generated for code using the old method signatures, which makes it easier to find the code that needs to be updated.

If ReferenceMaker::NotifyRefChanged() is called through ReferenceMaker::NotifyDependents(), the value of 'propagate' is that passed to ReferenceMaker::NotifyDependents().

If the plug-in directly calls an implementation of ReferenceMaker::NotifyRefChanged(), the correct value to pass for the "propagate" parameter depends on its actual behavior (implementation details). A common case is when an implementation of ReferenceMaker::NotifyRefChanged() calls the parent's class implementation of the same method, in which case the plug-in should just pass the received value for the "propagate" parameter. Another common case is when the plug-in needs to update or request information from a reference maker to which it may hold a simple pointer (which is not a recommended practice). In most but not all of these cases FALSE should be passed in as the value of the "propagate" flag.

If the plug-in needs to call ReferenceMaker::NotifyDependents() from its implementation of ReferenceMaker::NotifyRefChanged(), it would normally do so only if the "propagate" flag passed to NotifiyDependents() is TRUE.

Changes in IRefTargContiner and IIndirectRefTargContainer

Improved support for reference management

You can now specify whether an instance of IRefTargContainer holds strong or weak references when you create the instance (strong references are the default behavior). GetHoldAsWeakReference() and SetHoldAsWeakReference() can also be used to determine this behavior. Note that indirect references are always treated as weak, regardless of this setting.

There is now a revised set of reference messages to allow owners of IRefTargContainers to know when an element has been removed, added, set or nulled:

See IRefTargContainer in the C++ API Reference for more information.

MAXScript exposure

RefTargContainer and IndirectRefTargContainer instances can be now created in MAXScript, as in this example:

rtc = RefTargContainer ()
showinterfaces rtc

irtc = IndirectRefTargContainer()
showinterfaces irtc

See the MAXScript Guide for more information.