Skip to content

Commit

Permalink
[TIMOB-25471] Improve KrollProxy validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Nov 1, 2017
1 parent da0ca41 commit 972613e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
21 changes: 17 additions & 4 deletions android/titanium/src/java/org/appcelerator/kroll/KrollProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ public void setIndexedProperty(int index, Object value)
*/
public boolean hasProperty(String name)
{
return properties.containsKey(name);
if (properties != null) {
return properties.containsKey(name);
}
return false;
}

/**
Expand All @@ -587,7 +590,10 @@ public boolean hasProperty(String name)
*/
public boolean hasPropertyAndNotNull(String name)
{
return properties.containsKeyAndNotNull(name);
if (properties != null) {
return properties.containsKeyAndNotNull(name);
}
return false;
}

/**
Expand All @@ -599,7 +605,10 @@ public boolean hasPropertyAndNotNull(String name)
*/
public Object getProperty(String name)
{
return properties.get(name);
if (properties != null) {
return properties.get(name);
}
return null;
}

/**
Expand All @@ -608,6 +617,10 @@ public Object getProperty(String name)
*/
public void setProperty(String name, Object value)
{
if (properties == null) {
return;
}

properties.put(name, value);

if (KrollRuntime.getInstance().isRuntimeThread()) {
Expand Down Expand Up @@ -826,7 +839,7 @@ public boolean fireSyncEvent(String event, Object data, long maxTimeout)
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean doFireEvent(String event, Object data)
{
if (!hierarchyHasListener(event)) {
if (!hierarchyHasListener(event) || eventListeners == null) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ public boolean isInForeground()
return inForeground;
}

public boolean isDestroyed()
{
return onDestroyFired;
}

protected void sendMessage(final int msgId)
{
if (messenger == null || msgId == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ public void transferView(TiUIView transferview, TiViewProxy oldProxy) {
*/
public TiUIView getOrCreateView()
{
if (activity == null || view != null) {
TiBaseActivity activity = (TiBaseActivity) getActivity();
if (activity == null || activity.isDestroyed() || view != null) {
return view;
}

Expand Down

0 comments on commit 972613e

Please sign in to comment.