summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-01-09 18:42:49 -0800
committerRomain Guy <romainguy@google.com>2012-01-09 18:42:49 -0800
commit10b0684296a1fbdc6966f54f77e821a9ce4852ad (patch)
tree8e255ffbe51a1702e1ddb4cd99f73a37134fa575 /graphics/java
parent32313b161f7c7d17841bf49b3d146fd19dd7fde1 (diff)
downloadframeworks_base-10b0684296a1fbdc6966f54f77e821a9ce4852ad.zip
frameworks_base-10b0684296a1fbdc6966f54f77e821a9ce4852ad.tar.gz
frameworks_base-10b0684296a1fbdc6966f54f77e821a9ce4852ad.tar.bz2
Prevent the GC from destroying the underlying native object
Change-Id: I9aaba5d82828af83dad8e6a270d2ab8c92b42be5
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/PathMeasure.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/graphics/java/android/graphics/PathMeasure.java b/graphics/java/android/graphics/PathMeasure.java
index 98f7821..7062824 100644
--- a/graphics/java/android/graphics/PathMeasure.java
+++ b/graphics/java/android/graphics/PathMeasure.java
@@ -17,6 +17,7 @@
package android.graphics;
public class PathMeasure {
+ private Path mPath;
/**
* Create an empty PathMeasure object. To uses this to measure the length
@@ -28,6 +29,7 @@ public class PathMeasure {
* is used. If the path is modified, you must call setPath with the path.
*/
public PathMeasure() {
+ mPath = null;
native_instance = native_create(0, false);
}
@@ -46,8 +48,8 @@ public class PathMeasure {
* even if its contour was not explicitly closed.
*/
public PathMeasure(Path path, boolean forceClosed) {
- // note: the native side makes a copy of path, so we don't need a java
- // reference to it here, since it's fine if it gets GC'd
+ // The native implementation does not copy the path, prevent it from being GC'd
+ mPath = path;
native_instance = native_create(path != null ? path.ni() : 0,
forceClosed);
}
@@ -56,8 +58,7 @@ public class PathMeasure {
* Assign a new path, or null to have none.
*/
public void setPath(Path path, boolean forceClosed) {
- // note: the native side makes a copy of path, so we don't need a java
- // reference to it here, since it's fine if it gets GC'd
+ mPath = path;
native_setPath(native_instance,
path != null ? path.ni() : 0,
forceClosed);