Touchpose icon indicating copy to clipboard operation
Touchpose copied to clipboard

Crash When Disabling TouchPose

Open phoney opened this issue 9 years ago • 3 comments

I'm working on a demo app where I want the user to be able to enable/disable Touchpose. To enable/disable Touchpose I call

((QTouchposeApplication *)[UIApplication sharedApplication]).alwaysShowTouches = isShowingTaps;
((QTouchposeApplication *)[UIApplication sharedApplication]).showTouches = isShowingTaps;

where isShowingTaps is a BOOL.

When disabling Touchpose I get a crash in QTouchposeFingerView:removeFromSuperview inside the call to super. This is called from setShowTouches:

The only way I could fix this was to move the animation from QTouchposeFingerView:removeFromSuperview to QApplication:UpdateTouches, and remove the QTouchposeFingerView:removeFromSuperview override.

Like this

           if (fingerView != NULL)
            {
                // Remove the touch from the 
                CFDictionaryRemoveValue(_touchDictionary, (__bridge const void *)(touch));
// The fingerView override of removeFromSuperview crashes when turning off showTouches
// after it was already on. Moving the animation here fixes the problem.
               [UIView animateWithDuration:_touchEndAnimationDuration animations:^{
                    fingerView.alpha = 0.0f;
                    fingerView.layer.transform = _touchEndTransform;
                } completion:^(BOOL completed){
                    [fingerView removeFromSuperview];
                }];
            }

phoney avatar Jun 26 '15 16:06 phoney

bump. I'm getting the same issue.

satchnut avatar Jan 15 '16 18:01 satchnut

@toddreed Thank you for the library! I've also experienced this crash: https://stackoverflow.com/questions/67689067/can-we-check-if-an-objc-object-was-deallocated-before-bridging-it-from-void-t Have you considered changing CFDictionary to NSMapTable (in the develop branch)?

gatamar avatar May 25 '21 18:05 gatamar

@gatamar: I created a new issue (#22) for this, as I think it’s an unrelated crash. I pushed a commit (525ce7ba2ce42cde2c31a8a66d0e547d11f97c42) to develop that should fix this (that is #22). Please try it out and let me know if that resolves your crash.

toddreed avatar May 28 '21 20:05 toddreed