summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2023-05-31 20:35:30 (GMT)
committerfvogel <fvogelnew1@free.fr>2023-05-31 20:35:30 (GMT)
commit36ecdb06871a56957e1ccb3b2b42fcf80a6884b0 (patch)
treea21339410dbe727554a96c916481698052aa74b7 /macosx
parentefe68a274280efc7a3e3fb5eec27a20d4b04ad89 (diff)
parente3da29cf61df71a71a4a9aafe55b52b7ea2aab22 (diff)
downloadtk-36ecdb06871a56957e1ccb3b2b42fcf80a6884b0.zip
tk-36ecdb06871a56957e1ccb3b2b42fcf80a6884b0.tar.gz
tk-36ecdb06871a56957e1ccb3b2b42fcf80a6884b0.tar.bz2
Fix [4666f21a95]: Avoid a non-evident crash.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXEmbed.c9
-rw-r--r--macosx/tkMacOSXKeyEvent.c9
-rw-r--r--macosx/tkMacOSXMouseEvent.c15
-rw-r--r--macosx/tkMacOSXSubwindows.c2
-rw-r--r--macosx/tkMacOSXWm.c4
5 files changed, 24 insertions, 15 deletions
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index 9a03178..72f2870 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -476,6 +476,10 @@ TkMacOSXGetHostToplevel(
{
TkWindow *contWinPtr, *topWinPtr;
+ if (!(winPtr && winPtr->privatePtr)) {
+ return NULL;
+ }
+
topWinPtr = winPtr->privatePtr->toplevel->winPtr;
if (!Tk_IsEmbedded(topWinPtr)) {
return winPtr->privatePtr->toplevel;
@@ -486,9 +490,6 @@ TkMacOSXGetHostToplevel(
* TODO: Here we should handle out of process embedding.
*/
- if (!contWinPtr) {
- return NULL;
- }
return TkMacOSXGetHostToplevel(contWinPtr);
}
@@ -700,7 +701,7 @@ TkpGetOtherWindow(
* process...
*/
- if (!(winPtr->flags & TK_BOTH_HALVES)) {
+ if (!(winPtr && (winPtr->flags & TK_BOTH_HALVES))) {
return NULL;
}
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index a6ab89b..59218ce 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -660,9 +660,12 @@ setXEventPoint(
local.x -= contPtr->wmInfoPtr->xInParent;
local.y -= contPtr->wmInfoPtr->yInParent;
} else {
- TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
- local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
- local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ MacDrawable *topMacWin = TkMacOSXGetHostToplevel(winPtr);
+ if (topMacWin) {
+ TkWindow *topPtr = topMacWin->winPtr;
+ local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
+ local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ }
}
} else if (winPtr->wmInfoPtr != NULL) {
local.x -= winPtr->wmInfoPtr->xInParent;
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 0286343..2853db9 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -308,6 +308,7 @@ enum {
if ([NSApp tkDragTarget]) {
TkWindow *dragPtr = (TkWindow *) [NSApp tkDragTarget];
TKWindow *dragWindow = nil;
+ MacDrawable *topMacWin;
if (dragPtr) {
dragWindow = (TKWindow *)TkMacOSXGetNSWindowForDrawable(
dragPtr->window);
@@ -317,7 +318,10 @@ enum {
target = NULL;
return theEvent;
}
- winPtr = TkMacOSXGetHostToplevel((TkWindow *) [NSApp tkDragTarget])->winPtr;
+ topMacWin = TkMacOSXGetHostToplevel(dragPtr);
+ if (topMacWin) {
+ winPtr = topMacWin->winPtr;
+ }
} else if (eventType == NSScrollWheel) {
winPtr = scrollTarget;
} else {
@@ -357,9 +361,12 @@ enum {
local.x -= contPtr->wmInfoPtr->xInParent;
local.y -= contPtr->wmInfoPtr->yInParent;
} else {
- TkWindow *topPtr = TkMacOSXGetHostToplevel(winPtr)->winPtr;
- local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
- local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ MacDrawable *topMacWin = TkMacOSXGetHostToplevel(winPtr);
+ if (topMacWin) {
+ TkWindow* topPtr = topMacWin->winPtr;
+ local.x -= (topPtr->wmInfoPtr->xInParent + contPtr->changes.x);
+ local.y -= (topPtr->wmInfoPtr->yInParent + contPtr->changes.y);
+ }
}
}
else {
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 6b5afe0..9d70d3a 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -87,6 +87,7 @@ XDestroyWindow(
if (macWin->toplevel->referenceCount == 0) {
ckfree(macWin->toplevel);
}
+ macWin->winPtr->privatePtr = NULL;
ckfree(macWin);
return Success;
}
@@ -103,6 +104,7 @@ XDestroyWindow(
macWin->drawRgn = NULL;
}
macWin->view = nil;
+ macWin->winPtr->privatePtr = NULL;
/*
* Delay deletion of a toplevel data structure until all children have
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index a13455b..c87cd08 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -910,7 +910,6 @@ TkWmDeadWindow(
{
WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2;
TKWindow *deadNSWindow;
- TkWindow *dragTarget = [NSApp tkDragTarget];
if (wmPtr == NULL) {
return;
@@ -990,9 +989,6 @@ TkWmDeadWindow(
* state which is recorded in the NSApplication object.
*/
- if (dragTarget && winPtr == TkMacOSXGetHostToplevel(dragTarget)->winPtr) {
- [NSApp setTkDragTarget:nil];
- }
if (winPtr == [NSApp tkPointerWindow]) {
NSWindow *w;
NSPoint mouse = [NSEvent mouseLocation];