X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7e1bcfa80e19ac853b8bc7084075fe3b01e63f03..e1983ab58804a0e32ab2d832ded0349af1cc0476:/src/motif/dialog.cpp diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index 1e3191c27e..393429dc1f 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -9,7 +9,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "dialog.h" #endif @@ -168,7 +168,8 @@ bool wxDialog::DoCreate( wxWindow* parent, wxWindowID id, XtSetArg (args[0], XmNdefaultPosition, False); XtSetArg (args[1], XmNautoUnmanage, False); Widget dialogShell = - XmCreateBulletinBoardDialog( parentWidget, (char*)name.c_str(), + XmCreateBulletinBoardDialog( parentWidget, + wxConstCast(name.c_str(), char), args, 2); m_mainWidget = (WXWidget) dialogShell; @@ -207,6 +208,7 @@ void wxDialog::SetModal(bool flag) wxDialog::~wxDialog() { m_isBeingDeleted = TRUE; + delete m_eventLoop; if (m_mainWidget) @@ -220,6 +222,9 @@ wxDialog::~wxDialog() { XtUnmapWidget((Widget) m_mainWidget); } + + PreDestroy(); + DoDestroy(); } void wxDialog::DoDestroy() @@ -300,8 +305,8 @@ bool wxDialog::Show( bool show ) else XtUnmanageChild((Widget)m_mainWidget) ; - XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())); - XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE); + XFlush(XtDisplay((Widget)m_mainWidget)); + XSync(XtDisplay((Widget)m_mainWidget), FALSE); } return TRUE; @@ -314,6 +319,9 @@ int wxDialog::ShowModal() Show(TRUE); + // after the event loop ran, the widget might already have been destroyed + WXDisplay* display = (WXDisplay*)XtDisplay( (Widget)m_mainWidget ); + if (m_modalShowing) return 0; m_eventLoop = new wxEventLoop; @@ -324,12 +332,7 @@ int wxDialog::ShowModal() m_eventLoop->Run(); // Now process all events in case they get sent to a destroyed dialog - XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE); - while (m_eventLoop->Pending()) - { - XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())); - m_eventLoop->Dispatch(); - } + wxFlushEvents( display ); delete m_eventLoop; m_eventLoop = NULL; @@ -440,11 +443,11 @@ void wxDialog::ChangeFont(bool keepOriginalSize) void wxDialog::ChangeBackgroundColour() { if (GetMainWidget()) - DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour); + wxDoChangeBackgroundColour(GetMainWidget(), m_backgroundColour); } void wxDialog::ChangeForegroundColour() { if (GetMainWidget()) - DoChangeForegroundColour(GetMainWidget(), m_foregroundColour); + wxDoChangeForegroundColour(GetMainWidget(), m_foregroundColour); }