flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vitali Kabak (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (FLEX-33052) Runtime error when using a chart in a module in an app that is also using charts
Date Thu, 22 Aug 2013 12:04:51 GMT

    [ https://issues.apache.org/jira/browse/FLEX-33052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13747439#comment-13747439
] 

Vitali Kabak edited comment on FLEX-33052 at 8/22/13 12:03 PM:
---------------------------------------------------------------

This issue is critical for our project and a suggested workaround does't fix the problem completely.
So let me describe this issue in details and suggest a way to fix it in SDK (I didn't find
a way to do this in our app).

In order to reproduce: create new project ParentApp with 2 MXML applications:
ParentApp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx: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"
				>
	
	<fx:Script>
		<![CDATA[
			import mx.charts.renderers.WedgeItemRenderer;
			WedgeItemRenderer;
		]]>
	</fx:Script>
	
	<s:SWFLoader source="ChildApp.swf"/>
</mx:Application>

ChildApp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx: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" 
				creationComplete="addChild(new ColumnChart());"
				>
	<fx:Script>
		<![CDATA[
			import mx.charts.ColumnChart;
		]]>
	</fx:Script>
</mx:Application>

Run ParentApp, get exception at ChartBase.initStyles(), where it tries to retrieve styleManager.getStyleDeclaration("mx.charts.chartClasses.ChartBase")
and gets null.
Now, what happens inside.
If you enable compiler option "-keep" in order to keep generated ActionScript code, you will
see 2 classes with names like _ParentApp_Styles.as and _ChildApp_Styles.as
When parent app starts, it creates all required styles in _ParentApp_Styles.as (including
styles for chart classes).
When child app starts, it also tries to create all required styles in _ChildApp_Styles.as.
But... 

mergedStyle = styleManager.getMergedStyleDeclaration("mx.charts.chartClasses.ChartBase");

getMergedStyleDeclaration returns an existing style declaration from parent app. So new style
declaration IN THIS STYLE MANAGER (style manager of the child app) is not created (notice
"if" case in generated code).

Now when you add a chart to the display list in child app, it calls ChartBase.initStyles()
method, where it tries to get style declaration for "mx.charts.chartClasses.ChartBase"
But it is null (this style is defined on parent). And we have an exception.

Please note that the same problem exists in almost all chart classes.

Other framework classes, which use styleManager.getStyleDeclaration, always check that style
is not null before using it.

I tried a similar workaround as suggested above, but it doesn't help in all cases. I will
continue description in the next comment.
                
      was (Author: kivinm):
    This issue is critical for our project and a suggested workaround does't fix the problem
completely.
So let me describe this issue in details and suggest a way to fix it in SDK (I didn't find
a way to do this in our app).

In order to reproduce: create new project ParentApp with 2 MXML applications:
ParentApp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx: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"
				>
	
	<fx:Script>
		<![CDATA[
			import mx.charts.renderers.WedgeItemRenderer;
			WedgeItemRenderer;
		]]>
	</fx:Script>
	
	<s:SWFLoader source="ChildApp.swf"/>
</mx:Application>

ChildApp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx: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" 
				creationComplete="addChild(new ColumnChart());"
				>
	<fx:Script>
		<![CDATA[
			import mx.charts.ColumnChart;
		]]>
	</fx:Script>
</mx:Application>

Run ParentApp, get exception at ChartBase.initStyles(), where it tries to retrieve styleManager.getStyleDeclaration("mx.charts.chartClasses.ChartBase")
and gets null.
Now, what happens inside.
If you enable compiler option "-keep" in order to keep generated ActionScript code, you will
see 2 classes with names like _ParentApp_Styles.as and _ChildApp_Styles.as
When parent app starts, it creates all required styles in _ParentApp_Styles.as (including
styles for chart classes).
When child app starts, it also tries to creates all required styles in _ChildApp_Styles.as.
But... 

mergedStyle = styleManager.getMergedStyleDeclaration("mx.charts.chartClasses.ChartBase");

getMergedStyleDeclaration returns an existing style declaration from parent app. So new style
declaration IN THIS STYLE MANAGER (style manager of the child app) is not created (notice
"if" case in generated code).

Now when you add a chart to the display list in child app, it calls ChartBase.initStyles()
method, where it tries to get style declaration for "mx.charts.chartClasses.ChartBase"
But it is null (this style is defined on parent). And we have an exception.

Please note that the same problem exists in almost all chart classes.

Other framework classes, which use styleManager.getStyleDeclaration, always check that style
is not null before using it.

I tried a similar workaround as suggested above, but it doesn't help in all cases. I will
continue description in the next comment.
                  
> Runtime error when using a chart in a module in an app that is also using charts
> --------------------------------------------------------------------------------
>
>                 Key: FLEX-33052
>                 URL: https://issues.apache.org/jira/browse/FLEX-33052
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Charts
>    Affects Versions: Adobe Flex SDK Previous
>         Environment: Affected OS(s): All OS Platforms
> Language Found: English
>            Reporter: Adobe JIRA
>
> This is a regression in 4.6. It doesn't matter if the modules are Spark or not. Works
fine in 4.5.1 and below.
> See attached FB project.
> Steps to reproduce:
> 1. Create an app that uses a chart and create a module that also uses a chart.
>  
>  Actual Results:
>  
> TypeError: Error #1009: Cannot access a property or method of a null object reference.
> 	at mx.charts.chartClasses::ChartBase/initStyles()[E:\dev\4.y\frameworks\projects\charts\src\mx\charts\chartClasses\ChartBase.as:1862]
>  
>  Expected Results:
>  
> No error and chart loads fine.
>  
>  Workaround (if any):
>  
>  Copy chart styles from module's parent styleManager into the module's own styleManager.

--
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

Mime
View raw message