X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=0.6.x%2Fjs%2F00_core%2F04_XClass.js;fp=0.6.x%2Fjs%2F00_core%2F04_XClass.js;h=76e0957c2bee9a7828d2dc45e85ec02f4e5808cb;hb=48057de05a25c032861e9f989a5c93baaf290d93;hp=2de9d36a024f7622f5e3825b06bb7967d8542e59;hpb=05d60a7e55a635b3948204a577d9dcf2961e344b;p=pettanr%2FclientJs.git diff --git a/0.6.x/js/00_core/04_XClass.js b/0.6.x/js/00_core/04_XClass.js index 2de9d36..76e0957 100644 --- a/0.6.x/js/00_core/04_XClass.js +++ b/0.6.x/js/00_core/04_XClass.js @@ -99,17 +99,35 @@ X.Class = ( function(){ klass = X.Class._getClass( instance ), def = X.Class._getClassDef( klass ), data, p, i; - if( def.isPrivate === true && killPrivateFlag === false ){ + if( def.isPrivate && !killPrivateFlag ){ X.Notification.critical( 'PrivateInstance.kill() work in PrivateUser.kill().' ); return; }; killPrivateFlag = false; // onKill 内で PrivateInstance.kill() を防ぐため + // onKill() === false の場合、kill のキャンセル // private は false での キャンセル は無視される - // TODO kill instance event + if( this.instanceOf( X.EventDispatcher ) ){ + if( !def.isPrivate ){ + if( this._dispatching ){ + this.dispatch( X.Event.BEFORE_KILL_INSTANCE ); + this._killReserved = true; + this.dispatch( X.Event.KILL_INSTANCE_CANCELED ); + return; + } else + if( this.dispatch( X.Event.BEFORE_KILL_INSTANCE ) & X.Callback.PREVENT_DEFAULT ){ + this.dispatch( X.Event.KILL_INSTANCE_CANCELED ); + return; + }; + }; + this.dispatch( X.Event.BEFORE_KILL_INSTANCE ); + this.dispatch( X.Event.KILL_INSTANCE ); + this._listeners && this.unlisten(); + } else if( X.Type.isFunction( instance.onKill ) && instance.onKill() === false && !def.isPrivate ){ return; }; + for( p in instance ){ if( instance.hasOwnProperty && !instance.hasOwnProperty( p ) ) continue; delete instance[ p ]; @@ -123,7 +141,11 @@ X.Class = ( function(){ if( i !== -1 ){ data = X.Class._getPrivate( instance ); killPrivateFlag = true; - data.kill(); + if( data._dispatching && data.instanceOf( X.EventDispatcher ) ){ + data._killReserved = true; + } else { + data.kill(); + }; def.dataList.splice( i, 1 ); def.userList.splice( i, 1 ); };