mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-06 06:08:24 +08:00
fix viewdraghelper's crash with invalid PointerId
This commit is contained in:
parent
6afd464ace
commit
e8ccf6b9ed
@ -403,6 +403,7 @@ void TouchDevice::setAxisValue(int raw_axis,int value,bool isRelative){
|
||||
switch(raw_axis){
|
||||
case ABS_X ... ABS_Z :
|
||||
mSlotID = 0 ; mTrackID = 0;
|
||||
mProp.id = 0;
|
||||
mDeviceClasses &= ~INPUT_DEVICE_CLASS_TOUCH_MT;
|
||||
break;
|
||||
case ABS_MT_POSITION_X...ABS_MT_POSITION_Y:
|
||||
|
@ -294,13 +294,13 @@ void ViewDragHelper::clearMotionHistory(int pointerId) {
|
||||
|
||||
void ViewDragHelper::ensureMotionHistorySizeForId(int pointerId) {
|
||||
if (mInitialMotionX.size() <= pointerId) {
|
||||
mInitialMotionX.resize(pointerId + 1);// = imx;
|
||||
mInitialMotionY.resize(pointerId + 1);// = imy;
|
||||
mLastMotionX.resize(pointerId + 1);// = lmx;
|
||||
mLastMotionY.resize(pointerId + 1);// = lmy;
|
||||
mInitialEdgesTouched.resize(pointerId + 1);// = iit;
|
||||
mEdgeDragsInProgress.resize(pointerId + 1);// = edip;
|
||||
mEdgeDragsLocked.resize(pointerId + 1);// = edl;
|
||||
//mInitialMotionX.resize(pointerId + 1);// = imx;
|
||||
//mInitialMotionY.resize(pointerId + 1);// = imy;
|
||||
//mLastMotionX.resize(pointerId + 1);// = lmx;
|
||||
//mLastMotionY.resize(pointerId + 1);// = lmy;
|
||||
//mInitialEdgesTouched.resize(pointerId + 1);// = iit;
|
||||
//mEdgeDragsInProgress.resize(pointerId + 1);// = edip;
|
||||
//mEdgeDragsLocked.resize(pointerId + 1);// = edl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -748,7 +748,8 @@ bool ViewDragHelper::isEdgeTouched(int edges)const{
|
||||
}
|
||||
|
||||
bool ViewDragHelper::isEdgeTouched(int edges, int pointerId)const{
|
||||
return isPointerDown(pointerId) && (mInitialEdgesTouched[pointerId] & edges) != 0;
|
||||
auto it = mInitialEdgesTouched.find(pointerId);
|
||||
return isPointerDown(pointerId) && (it->second & edges) != 0;
|
||||
}
|
||||
|
||||
void ViewDragHelper::releaseViewForPointerUp() {
|
||||
|
@ -73,13 +73,13 @@ private:
|
||||
|
||||
// Last known position/pointer tracking
|
||||
int mActivePointerId = INVALID_POINTER;
|
||||
std::vector<float> mInitialMotionX;
|
||||
std::vector<float> mInitialMotionY;
|
||||
std::vector<float> mLastMotionX;
|
||||
std::vector<float> mLastMotionY;
|
||||
std::vector<int> mInitialEdgesTouched;
|
||||
std::vector<int> mEdgeDragsInProgress;
|
||||
std::vector<int> mEdgeDragsLocked;
|
||||
std::map<int,float> mInitialMotionX;
|
||||
std::map<int,float> mInitialMotionY;
|
||||
std::map<int,float> mLastMotionX;
|
||||
std::map<int,float> mLastMotionY;
|
||||
std::map<int,int> mInitialEdgesTouched;
|
||||
std::map<int,int> mEdgeDragsInProgress;
|
||||
std::map<int,int> mEdgeDragsLocked;
|
||||
int mPointersDown;
|
||||
|
||||
VelocityTracker* mVelocityTracker;
|
||||
|
Loading…
Reference in New Issue
Block a user