Tk

 view release on metacpan or  search on metacpan

pTk/mTk/generic/tkWindow.c  view on Meta::CPAN

            /*
             * The memory pointed to by pathName has been deallocated.
             * Keep users from accessing it after the window has been
             * destroyed by setting it to NULL.
             */
            winPtr->pathName = NULL;

	    /*
	     * Invalidate all objects referring to windows
	     * with the same main window
	     */
	    winPtr->mainPtr->deletionEpoch++;
	}
	winPtr->mainPtr->refCount--;
	if (winPtr->mainPtr->refCount == 0) {

	    /*
	     * We just deleted the last window in the application.  Delete
	     * the TkMainInfo structure too and replace all of Tk's commands
	     * with dummy commands that return errors.	Also delete the
	     * "send" command to unregister the interpreter.
	     *
	     * NOTE: Only replace the commands it if the interpreter is
	     * not being deleted. If it *is*, the interpreter cleanup will
	     * do all the needed work.
	     */

#if 1 /* Do a Lang dependant cleanup */
            Lang_DeadMainWindow(winPtr->mainPtr->interp, (Tk_Window) winPtr);
            Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif");
#else /* This is what Tcl does */
            if ((winPtr->mainPtr->interp != NULL) &&
                    (!Tcl_InterpDeleted(winPtr->mainPtr->interp))) {
                for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) {
                    Tcl_CreateCommand(winPtr->mainPtr->interp, cmdPtr->name,
                            TkDeadAppCmd, (ClientData) NULL,
                            (void (*) _ANSI_ARGS_((ClientData))) NULL);
                }
                Tcl_CreateCommand(winPtr->mainPtr->interp, "send",
                        TkDeadAppCmd, (ClientData) NULL,
                        (void (*) _ANSI_ARGS_((ClientData))) NULL);
                Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif");
            }

#endif
	    Tcl_DeleteHashTable(&winPtr->mainPtr->nameTable);
	    TkBindFree(winPtr->mainPtr);
	    /* Do images before fonts - they may use fonts ... */
	    TkDeleteAllImages(winPtr->mainPtr);
	    TkFontPkgFree(winPtr->mainPtr);
	    TkFocusFree(winPtr->mainPtr);
	    TkStylePkgFree(winPtr->mainPtr);

            /*
             * When embedding Tk into other applications, make sure
             * that all destroy events reach the server. Otherwise
             * the embedding application may also attempt to destroy
             * the windows, resulting in an X error
             */

            if (winPtr->flags & TK_EMBEDDED) {
                XSync(winPtr->display, False);
            }
	    ckfree((char *) winPtr->mainPtr);

            /*
             * If no other applications are using the display, close the
             * display now and relinquish its data structures.
             */

#if !defined(WIN32) && !defined(MAC_TCL) && defined(NOT_YET)
            if (dispPtr->refCount <= 0) {
                /*
                 * I have disabled this code because on Windows there are
                 * still order dependencies in close-down. All displays
                 * and resources will get closed down properly anyway at
                 * exit, through the exit handler. -- jyl
                 */
		/*
		 * Ideally this should be enabled, as unix Tk can use multiple
		 * displays.  However, there are order issues still, as well
		 * as the handling of queued events and such that must be
		 * addressed before this can be enabled.  The current cleanup
		 * works except for send event issues. -- hobbs 04/2002
		 */

                TkDisplay *theDispPtr, *backDispPtr;

                /*
                 * Splice this display out of the list of displays.
                 */

                for (theDispPtr = tsdPtr->displayList, backDispPtr = NULL;
                         (theDispPtr != winPtr->dispPtr) &&
                             (theDispPtr != NULL);
                         theDispPtr = theDispPtr->nextPtr) {
                    backDispPtr = theDispPtr;
                }
                if (theDispPtr == NULL) {
                    panic("could not find display to close!");
                }
                if (backDispPtr == NULL) {
                    tsdPtr->displayList = theDispPtr->nextPtr;
                } else {
                    backDispPtr->nextPtr = theDispPtr->nextPtr;
                }

                /*
		 * Calling XSync creates X server traffic, but addresses a
		 * focus issue on close (but not the send issue). -- hobbs
		 XSync(dispPtr->display, True);
		 */

                /*
                 * Found and spliced it out, now actually do the cleanup.
                 */

		TkCloseDisplay(dispPtr);
            }
#endif
	}



( run in 0.951 second using v1.01-cache-2.11-cpan-71847e10f99 )