Merge "Fixed some minor bugs in MotionEvent recycling." into kraken
This commit is contained in:
@@ -255,17 +255,19 @@ public final class MotionEvent implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static private MotionEvent obtain() {
|
static private MotionEvent obtain() {
|
||||||
|
final MotionEvent ev;
|
||||||
synchronized (gRecyclerLock) {
|
synchronized (gRecyclerLock) {
|
||||||
if (gRecyclerTop == null) {
|
if (gRecyclerTop == null) {
|
||||||
return new MotionEvent();
|
return new MotionEvent();
|
||||||
}
|
}
|
||||||
MotionEvent ev = gRecyclerTop;
|
ev = gRecyclerTop;
|
||||||
gRecyclerTop = ev.mNext;
|
gRecyclerTop = ev.mNext;
|
||||||
gRecyclerUsed--;
|
gRecyclerUsed--;
|
||||||
ev.mRecycledLocation = null;
|
|
||||||
ev.mRecycled = false;
|
|
||||||
return ev;
|
|
||||||
}
|
}
|
||||||
|
ev.mRecycledLocation = null;
|
||||||
|
ev.mRecycled = false;
|
||||||
|
ev.mNext = null;
|
||||||
|
return ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -620,11 +622,14 @@ public final class MotionEvent implements Parcelable {
|
|||||||
throw new RuntimeException(toString() + " recycled twice!", mRecycledLocation);
|
throw new RuntimeException(toString() + " recycled twice!", mRecycledLocation);
|
||||||
}
|
}
|
||||||
mRecycledLocation = new RuntimeException("Last recycled here");
|
mRecycledLocation = new RuntimeException("Last recycled here");
|
||||||
} else if (mRecycled) {
|
//Log.w("MotionEvent", "Recycling event " + this, mRecycledLocation);
|
||||||
throw new RuntimeException(toString() + " recycled twice!");
|
} else {
|
||||||
|
if (mRecycled) {
|
||||||
|
throw new RuntimeException(toString() + " recycled twice!");
|
||||||
|
}
|
||||||
|
mRecycled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.w("MotionEvent", "Recycling event " + this, mRecycledLocation);
|
|
||||||
synchronized (gRecyclerLock) {
|
synchronized (gRecyclerLock) {
|
||||||
if (gRecyclerUsed < MAX_RECYCLED) {
|
if (gRecyclerUsed < MAX_RECYCLED) {
|
||||||
gRecyclerUsed++;
|
gRecyclerUsed++;
|
||||||
|
|||||||
Reference in New Issue
Block a user