You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by "Carlos Rovira (JIRA)" <ji...@apache.org> on 2013/03/24 13:35:15 UTC

[jira] [Updated] (FLEX-28967) PopUpManagerImpl - centerPopUp method - TypeError: Error #1009: Cannot access a property or method of a null object reference

     [ https://issues.apache.org/jira/browse/FLEX-28967?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carlos Rovira updated FLEX-28967:
---------------------------------

    Description: 
Steps to reproduce:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	
	<fx:Script>
		<![CDATA[
			import mx.managers.PopUpManager;
			protected function button1_clickHandler(event:MouseEvent):void
			{
				PopUpManager.centerPopUp(w);
			}
		]]>
	</fx:Script>
	
	<s:Button click="button1_clickHandler(event)"/>
	
	<s:TitleWindow id="w" bottom="10"/>
	
</s:Application>



1. using PopUpManager
 
Error in the code:
public function centerPopUp(popUp:IFlexDisplayObject):void
    {        
        if (popUp is IInvalidating)
            IInvalidating(popUp).validateNow();

        const o:PopUpData = findPopupInfoByOwner(popUp);
        
        // If we don't find the pop owner or if the owner's parent is not specified or is not on the
        // stage, then center based on the popUp's current parent.
        var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
        if (popUpParent)
        {
            var systemManager:ISystemManager = o.systemManager;
.
.
.
.

If const "o" is null, popUpParent is set to popUp.parent as stated by condition above.
However in next step you assume that const "o" exists because you're asking for o.systemManager, but o is null.
Therefore: TypeError: Error #1009: Cannot access a property or method of a null object reference


Fix:


public function centerPopUp(popUp:IFlexDisplayObject):void
    {        
        if (popUp is IInvalidating)
            IInvalidating(popUp).validateNow();

        const o:PopUpData = findPopupInfoByOwner(popUp);
        
        var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
        if (popUpParent)
        {
			var systemManager:ISystemManager;
			if (o != null) {
				systemManager = o.systemManager;
			} else if (popUpParent.hasOwnProperty("systemManager")) {
				systemManager = popUpParent["systemManager"];
			} else if (popUpParent is ISystemManager) {
				systemManager = popUpParent as ISystemManager;
			}
			
			if (!systemManager)
				return; // or throw exception maybe ?
.
.
.
.

  was:
Steps to reproduce:
1. using PopUpManager
 
Error in the code:
public function centerPopUp(popUp:IFlexDisplayObject):void
    {        
        if (popUp is IInvalidating)
            IInvalidating(popUp).validateNow();

        const o:PopUpData = findPopupInfoByOwner(popUp);
        
        // If we don't find the pop owner or if the owner's parent is not specified or is not on the
        // stage, then center based on the popUp's current parent.
        var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
        if (popUpParent)
        {
            var systemManager:ISystemManager = o.systemManager;
.
.
.
.

If const "o" is null, popUpParent is set to popUp.parent as stated by condition above.
However in next step you assume that const "o" exists because you're asking for o.systemManager, but o is null.
Therefore: TypeError: Error #1009: Cannot access a property or method of a null object reference


Fix:


public function centerPopUp(popUp:IFlexDisplayObject):void
    {        
        if (popUp is IInvalidating)
            IInvalidating(popUp).validateNow();

        const o:PopUpData = findPopupInfoByOwner(popUp);
        
        var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
        if (popUpParent)
        {
			var systemManager:ISystemManager;
			if (o != null) {
				systemManager = o.systemManager;
			} else if (popUpParent.hasOwnProperty("systemManager")) {
				systemManager = popUpParent["systemManager"];
			} else if (popUpParent is ISystemManager) {
				systemManager = popUpParent as ISystemManager;
			}
			
			if (!systemManager)
				return; // or throw exception maybe ?
.
.
.
.

    
> PopUpManagerImpl - centerPopUp method - TypeError: Error #1009: Cannot access a property or method of a null object reference
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLEX-28967
>                 URL: https://issues.apache.org/jira/browse/FLEX-28967
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: PopUp Manager
>    Affects Versions: Adobe Flex SDK Previous
>         Environment: Affected OS(s): All OS Platforms
> Affected OS(s): All OS Platforms
> Browser: Internet Explorer 8.x
> Language Found: English
>            Reporter: Adobe JIRA
>            Assignee: Carlos Rovira
>              Labels: EasyFix
>             Fix For: Apache Flex Next
>
>
> Steps to reproduce:
> <?xml version="1.0" encoding="utf-8"?>
> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
> 			   xmlns:s="library://ns.adobe.com/flex/spark" 
> 			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
> 	
> 	<fx:Script>
> 		<![CDATA[
> 			import mx.managers.PopUpManager;
> 			protected function button1_clickHandler(event:MouseEvent):void
> 			{
> 				PopUpManager.centerPopUp(w);
> 			}
> 		]]>
> 	</fx:Script>
> 	
> 	<s:Button click="button1_clickHandler(event)"/>
> 	
> 	<s:TitleWindow id="w" bottom="10"/>
> 	
> </s:Application>
> 1. using PopUpManager
>  
> Error in the code:
> public function centerPopUp(popUp:IFlexDisplayObject):void
>     {        
>         if (popUp is IInvalidating)
>             IInvalidating(popUp).validateNow();
>         const o:PopUpData = findPopupInfoByOwner(popUp);
>         
>         // If we don't find the pop owner or if the owner's parent is not specified or is not on the
>         // stage, then center based on the popUp's current parent.
>         var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
>         if (popUpParent)
>         {
>             var systemManager:ISystemManager = o.systemManager;
> .
> .
> .
> .
> If const "o" is null, popUpParent is set to popUp.parent as stated by condition above.
> However in next step you assume that const "o" exists because you're asking for o.systemManager, but o is null.
> Therefore: TypeError: Error #1009: Cannot access a property or method of a null object reference
> Fix:
> public function centerPopUp(popUp:IFlexDisplayObject):void
>     {        
>         if (popUp is IInvalidating)
>             IInvalidating(popUp).validateNow();
>         const o:PopUpData = findPopupInfoByOwner(popUp);
>         
>         var popUpParent:DisplayObject = (o && o.parent && o.parent.stage) ? o.parent : popUp.parent;
>         if (popUpParent)
>         {
> 			var systemManager:ISystemManager;
> 			if (o != null) {
> 				systemManager = o.systemManager;
> 			} else if (popUpParent.hasOwnProperty("systemManager")) {
> 				systemManager = popUpParent["systemManager"];
> 			} else if (popUpParent is ISystemManager) {
> 				systemManager = popUpParent as ISystemManager;
> 			}
> 			
> 			if (!systemManager)
> 				return; // or throw exception maybe ?
> .
> .
> .
> .

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira