| Ticket UUID: | 3205464 | |||
| Title: | [wm forget] lose window | |||
| Type: | Bug | Version: | None | |
| Submitter: | beric | Created on: | 2011-03-10 14:12:38 | |
| Subsystem: | 68. Win Window Operations | Assigned To: | patthoyts | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2011-03-19 07:51:09 | |
| Resolution: | Fixed | Closed By: | patthoyts | |
| Closed on: | 2011-03-19 00:51:09 | |||
| Description: |
Under Windows XP, Tk 8.5.9. If [wm forget $w] is called when $w original parent is not mapped, the window is "lost". The attached script demonstrates the problem: it creates a notebook with 5 tabs. Right click on a tab detach the content with [wm manage] in a toplevel. Close the toplevel, the content get back into tab page, but only if original tab page is raised. If you raise another page or iconify the application and then close the toplevel, the content is not visible anymore. Calling again [wm manage] on the same tab displays a toplevel without redraw. Looks like a flag is not well reset in [wm forget], although [wm ismapped] and [wm viewable] return 1. | |||
| User Comments: |
patthoyts added on 2011-03-19 07:51:09:
allow_comments - 1 Eric's solution 2 accepted. The original fix for 2009788 avoided a crash at the cost of loosing the windows if the parent was unmapped as identified here. I have added a test that detects this (winWm-9.2) and used solution 2 (call Tk_MakeWindowExist) though we don't need to check for the window being None as that is done in the function anyway. Applied to 8.5 and trunk. Thank you to both beric and danckaert. danckaert added on 2011-03-18 23:37:53: Note that this problem was reported earlier in bug 2967911. beric added on 2011-03-18 15:08:48: Pat, any comments? beric added on 2011-03-11 15:53:47: So in WmForgetCmd(), instead of:
if (Tk_IsMapped(Tk_Parent(frameWin))) {
RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window));
}
I have tried:
Solution 1:
if (winPtr->parentPtr->window) {
RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window));
}
Solution 2:
if (winPtr->parentPtr->window == None) {
Tk_MakeWindowExist((Tk_Window) winPtr->parentPtr);
}
RemapWindows(winPtr, Tk_GetHWND(winPtr->parentPtr->window));
The solution 1 works if the parent is not mapped, but not if it has not been realized (i.e. never been mapped, the window is not created). This is the case if the page is detached then attached without having been raised in the notebook.
The solution 2 always works, since it forces the creation of the window.
beric added on 2011-03-11 15:13:30: In my case, I want to keep the position of the tab, this is the reason why I use a "holder" frame, which is the one detached, and, in my real code, I do [$notebook hide $page]. patthoyts added on 2011-03-11 05:54:55: Interesting. I have an application that does this but I remove the tab from the notebook when I manage one of the tabs ($notebook forget $pane). Then in the re-attach function I ensure we have a tab for it to go back into and I see I $notebook select $tab ( http://www.patthoyts.tk/gitweb.cgi?p=Bullfrog;a=blob;f=bin/bullfrog.tcl;h=d0ca0e2a8d4981f99a41d07af3ae873939a9eb3a;hb=12f1d0dd0be06b9bef826ab2724900403a03a202#l301) Obviously it would be best to avoid surprising our users if we can manage that. beric added on 2011-03-11 01:22:40: Pat, looking at tkWinWm.c history, Tk_IsMapped() check comes from a change you made to fix bug 2009788. The bug is not due to the fact that the parent is not mapped, but that its window is not created. I think a better fix would be eitther check winPtr->parentPtr->window, or use Tk_MakeWindowExist() if really needed. I'll check tomorrow. beric added on 2011-03-10 21:53:18: In fact, RemapWindows() is not called if parent is not mapped. Why ? beric added on 2011-03-10 21:12:38: File Added - 403946: wm_manage.tcl | |||
Attachments:
- wm_manage.tcl [download] added by beric on 2011-03-10 21:12:38. [details]
