aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/NewtMacWindow.m
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-03 04:29:38 +0100
committerSven Gothel <[email protected]>2014-01-03 04:29:38 +0100
commitbb5c7496ed92b91dded30816a46b42ff85f37bec (patch)
treea07604394d72291734783e661379b137e2b5b6c9 /src/newt/native/NewtMacWindow.m
parent09db30c4a0d9c0f29c47af76238b2abc275301c0 (diff)
Bug 935: NEWT PointerIcon OSX: Safe use of NSCursor handle
Diffstat (limited to 'src/newt/native/NewtMacWindow.m')
-rw-r--r--src/newt/native/NewtMacWindow.m37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m
index 9f534e319..96965b67a 100644
--- a/src/newt/native/NewtMacWindow.m
+++ b/src/newt/native/NewtMacWindow.m
@@ -670,15 +670,23 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) {
}
}
-- (void) setCustomCursor:(NSCursor*)c
+- (void) setPointerIcon:(NSCursor*)c
{
+ DBG_PRINT( "setPointerIcon: mouseInside cursor: %p -> %p (glob %p), mouseInside %d\n", customCursor, c, [NSCursor currentCursor], (int)mouseInside);
if(YES == mouseInside) {
if( NULL != c ) {
- DBG_PRINT( "setCustomCursor push: %p\n", c);
+ DBG_PRINT( "setPointerIcon push: %p\n", c);
[c push];
- } else if( NULL != customCursor && [NSCursor currentCursor] == customCursor ) {
- DBG_PRINT( "setCustomCursor pop: %p\n", customCursor);
- [customCursor pop];
+ } else if( NULL != customCursor ) {
+ if ( NO == [customCursor isKindOfClass:[NSCursor class]] ) {
+ DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (2)\n", customCursor);
+ if( [NSCursor currentCursor] == customCursor ) {
+ [NSCursor pop];
+ }
+ } else if( [NSCursor currentCursor] == customCursor ) {
+ DBG_PRINT( "setPointerIcon pop: %p\n", customCursor);
+ [customCursor pop];
+ }
}
}
customCursor = c;
@@ -688,12 +696,19 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) {
{
DBG_PRINT( "cursorHide: %d -> %d, enter %d\n", cursorIsHidden, v, enterState);
if( NULL != customCursor ) {
- if( 1 == enterState && [NSCursor currentCursor] != customCursor ) {
- DBG_PRINT( "cursorHide.customCursor push: %p\n", customCursor);
- [customCursor push];
- } else if( -1 == enterState && [NSCursor currentCursor] == customCursor ) {
- DBG_PRINT( "cursorHide.customCursor pop: %p\n", customCursor);
- [customCursor pop];
+ if ( NO == [customCursor isKindOfClass:[NSCursor class]] ) {
+ DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (3)\n", customCursor);
+ if( [NSCursor currentCursor] == customCursor ) {
+ [NSCursor pop];
+ }
+ } else {
+ if( 1 == enterState && [NSCursor currentCursor] != customCursor ) {
+ DBG_PRINT( "cursorHide.PointerIcon push: %p\n", customCursor);
+ [customCursor push];
+ } else if( -1 == enterState && [NSCursor currentCursor] == customCursor ) {
+ DBG_PRINT( "cursorHide.PointerIcon pop: %p\n", customCursor);
+ [customCursor pop];
+ }
}
}
if(v) {