-#ifdef EXTERNAL_WIDGET
- expect_x_error (dpy);
- /* for obscure reasons having (I think) to do with the internal
- window-to-widget hierarchy maintained by Xt, we have to call
- XtUnrealizeWidget() here. Xt can really suck. */
- if (f->being_deleted)
- XtUnrealizeWidget (w);
- XtDestroyWidget (w);
- x_error_occurred_p (dpy);
-#else
- XtDestroyWidget (w);
- XFlush (dpy); /* make sure the windows are really gone! */
-#endif /* EXTERNAL_WIDGET */
+#ifdef HAVE_CDE
+ DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f));
+#endif /* HAVE_CDE */
+
+ assert (FRAME_X_SHELL_WIDGET (f));
+ if (FRAME_X_SHELL_WIDGET (f))
+ {
+ Display *dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f));
+ expect_x_error (dpy);
+ /* for obscure reasons having (I think) to do with the internal
+ window-to-widget hierarchy maintained by Xt, we have to call
+ XtUnrealizeWidget() here. Xt can really suck. */
+ if (f->being_deleted)
+ XtUnrealizeWidget (FRAME_X_SHELL_WIDGET (f));
+ XtDestroyWidget (FRAME_X_SHELL_WIDGET (f));
+ x_error_occurred_p (dpy);
+
+ /* make sure the windows are really gone! */
+ /* ### Is this REALLY necessary? */
+ XFlush (dpy);
+
+ FRAME_X_SHELL_WIDGET (f) = 0;
+ }