Fix null handling in setMatrix

This commit is contained in:
Mikael Sand
2017-07-22 18:12:22 +03:00
parent f9359a6236
commit 39cdabe17e
4 changed files with 15 additions and 3 deletions
@@ -60,7 +60,7 @@ class ImageShadowNode extends RenderableShadowNode {
0, 1, 0,
0, 0, 1
};
private Matrix mMatrix = new Matrix();
private Matrix mMatrix = null;
@ReactProp(name = "x")
public void setX(String x) {
@@ -123,6 +123,9 @@ class ImageShadowNode extends RenderableShadowNode {
if (matrixArray != null) {
int matrixSize = PropHelper.toMatrixData(matrixArray, sRawMatrix, mScale);
if (matrixSize == 6) {
if (mMatrix == null) {
mMatrix = new Matrix();
}
mMatrix.setValues(sRawMatrix);
} else if (matrixSize != -1) {
FLog.w(ReactConstants.TAG, "RNSVG: Transform matrices must be of size 6");
@@ -37,7 +37,7 @@ class LinearGradientShadowNode extends DefinitionShadowNode {
0, 1, 0,
0, 0, 1
};
private Matrix mMatrix = new Matrix();
private Matrix mMatrix = null;
@ReactProp(name = "x1")
public void setX1(String x1) {
@@ -87,6 +87,9 @@ class LinearGradientShadowNode extends DefinitionShadowNode {
if (matrixArray != null) {
int matrixSize = PropHelper.toMatrixData(matrixArray, sRawMatrix, mScale);
if (matrixSize == 6) {
if (mMatrix == null) {
mMatrix = new Matrix();
}
mMatrix.setValues(sRawMatrix);
} else if (matrixSize != -1) {
FLog.w(ReactConstants.TAG, "RNSVG: Transform matrices must be of size 6");
@@ -38,7 +38,7 @@ class RadialGradientShadowNode extends DefinitionShadowNode {
0, 1, 0,
0, 0, 1
};
private Matrix mMatrix = new Matrix();
private Matrix mMatrix = null;
@ReactProp(name = "fx")
public void setFx(String fx) {
@@ -100,6 +100,9 @@ class RadialGradientShadowNode extends DefinitionShadowNode {
if (matrixArray != null) {
int matrixSize = PropHelper.toMatrixData(matrixArray, sRawMatrix, mScale);
if (matrixSize == 6) {
if (mMatrix == null) {
mMatrix = new Matrix();
}
mMatrix.setValues(sRawMatrix);
} else if (matrixSize != -1) {
FLog.w(ReactConstants.TAG, "RNSVG: Transform matrices must be of size 6");
@@ -219,6 +219,9 @@ abstract class VirtualNode extends LayoutShadowNode {
if (matrixArray != null) {
int matrixSize = PropHelper.toMatrixData(matrixArray, sRawMatrix, mScale);
if (matrixSize == 6) {
if (mMatrix == null) {
mMatrix = new Matrix();
}
mMatrix.setValues(sRawMatrix);
} else if (matrixSize != -1) {
FLog.w(ReactConstants.TAG, "RNSVG: Transform matrices must be of size 6");