Fix crash on exit with Lesstif (and possibly Motif 1.x).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -105,6 +105,8 @@ public:
|
||||
// returns either a XmFontList or XmRendition, depending
|
||||
// on Motif version
|
||||
WXFontType GetFontType(WXDisplay* display) const;
|
||||
// like the function above but does a copy for XmFontList
|
||||
WXFontType GetFontTypeC(WXDisplay* display) const;
|
||||
static WXString GetFontTag();
|
||||
protected:
|
||||
virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
|
||||
|
@@ -76,7 +76,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl,
|
||||
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button",
|
||||
xmPushButtonWidgetClass,
|
||||
parentWidget,
|
||||
wxFont::GetFontTag(), m_font.GetFontType(XtDisplay(parentWidget)),
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)),
|
||||
XmNlabelString, text(),
|
||||
XmNrecomputeSize, False,
|
||||
// See comment for wxButton::SetDefault
|
||||
|
@@ -73,7 +73,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
|
||||
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle",
|
||||
xmToggleButtonWidgetClass, parentWidget,
|
||||
wxFont::GetFontTag(), m_font.GetFontType(XtDisplay(parentWidget)),
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)),
|
||||
XmNlabelString, text(),
|
||||
XmNrecomputeSize, False,
|
||||
// XmNindicatorOn, XmINDICATOR_CHECK_BOX,
|
||||
|
@@ -459,19 +459,22 @@ void wxChoice::ChangeFont(bool keepOriginalSize)
|
||||
// back again. TODO: a better way in Motif?
|
||||
if (m_font.Ok())
|
||||
{
|
||||
Display* dpy = XtDisplay((Widget) m_mainWidget);
|
||||
int width, height, width1, height1;
|
||||
GetSize(& width, & height);
|
||||
|
||||
WXFontType fontType =
|
||||
m_font.GetFontType(XtDisplay((Widget) m_mainWidget));
|
||||
WXString fontTag = wxFont::GetFontTag();
|
||||
|
||||
XtVaSetValues ((Widget) m_formWidget, fontTag, fontType, NULL);
|
||||
XtVaSetValues ((Widget) m_buttonWidget, fontTag, fontType, NULL);
|
||||
XtVaSetValues ((Widget) m_formWidget,
|
||||
fontTag, m_font.GetFontTypeC(dpy),
|
||||
NULL);
|
||||
XtVaSetValues ((Widget) m_buttonWidget,
|
||||
fontTag, m_font.GetFontTypeC(dpy),
|
||||
NULL);
|
||||
|
||||
for( size_t i = 0; i < m_noStrings; ++i )
|
||||
XtVaSetValues( (Widget)m_widgetArray[i],
|
||||
fontTag, fontType,
|
||||
fontTag, m_font.GetFontTypeC(dpy),
|
||||
NULL );
|
||||
|
||||
GetSize(& width1, & height1);
|
||||
|
@@ -46,6 +46,12 @@
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
|
||||
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
|
||||
#define wxUSE_RENDER_TABLE 1
|
||||
#else
|
||||
#define wxUSE_RENDER_TABLE 0
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// private classes
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -59,8 +65,9 @@ public:
|
||||
~wxXFont();
|
||||
|
||||
WXFontStructPtr m_fontStruct; // XFontStruct
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
WXFontList m_fontList; // Motif XmFontList
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 )
|
||||
#else // if wxUSE_RENDER_TABLE
|
||||
WXRenderTable m_renderTable; // Motif XmRenderTable
|
||||
#endif
|
||||
WXDisplay* m_display; // XDisplay
|
||||
@@ -127,8 +134,9 @@ protected:
|
||||
wxXFont::wxXFont()
|
||||
{
|
||||
m_fontStruct = (WXFontStructPtr) 0;
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
m_fontList = (WXFontList) 0;
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 )
|
||||
#else // if wxUSE_RENDER_TABLE
|
||||
m_renderTable = (WXRenderTable) 0;
|
||||
#endif
|
||||
m_display = (WXDisplay*) 0;
|
||||
@@ -137,16 +145,20 @@ wxXFont::wxXFont()
|
||||
|
||||
wxXFont::~wxXFont()
|
||||
{
|
||||
XmFontList fontList = (XmFontList) m_fontList;
|
||||
XmFontListFree (fontList);
|
||||
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
|
||||
XmRenderTable renderTable = (XmRenderTable) m_renderTable;
|
||||
XmRenderTableFree (renderTable);
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
if (m_fontList)
|
||||
XmFontListFree ((XmFontList) m_fontList);
|
||||
m_fontList = NULL;
|
||||
#else // if wxUSE_RENDER_TABLE
|
||||
if (m_renderTable)
|
||||
XmRenderTableFree ((XmRenderTable) m_renderTable);
|
||||
m_renderTable = NULL;
|
||||
#endif
|
||||
|
||||
// TODO: why does freeing the font produce a segv???
|
||||
// Note that XFreeFont wasn't called in wxWin 1.68 either.
|
||||
// MBN: probably some interaction with fonts being still
|
||||
// in use in some widgets...
|
||||
// XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
|
||||
// XFreeFont((Display*) m_display, fontStruct);
|
||||
}
|
||||
@@ -544,10 +556,10 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
f->m_fontStruct = (WXFontStructPtr)font;
|
||||
f->m_display = ( display ? display : wxGetDisplay() );
|
||||
f->m_scale = intScale;
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
|
||||
M_FONTDATA->m_fonts.Append(f);
|
||||
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
|
||||
#else // if wxUSE_RENDER_TABLE
|
||||
XmRendition rendition;
|
||||
XmRenderTable renderTable;
|
||||
Arg args[5];
|
||||
@@ -577,34 +589,52 @@ WXFontStructPtr wxFont::GetFontStruct(double scale, WXDisplay* display) const
|
||||
|
||||
WXFontList wxFont::GetFontList(double scale, WXDisplay* display) const
|
||||
{
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
wxXFont* f = GetInternalFont(scale, display);
|
||||
|
||||
return (f ? f->m_fontList : (WXFontList) 0);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
// declared in the header, can't use wxUSE_RENDER_TABLE
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 )
|
||||
|
||||
WXRenderTable wxFont::GetRenderTable(WXDisplay* display) const
|
||||
{
|
||||
#if wxUSE_RENDER_TABLE
|
||||
wxXFont* f = GetInternalFont(1.0, display);
|
||||
|
||||
return (f ? f->m_renderTable : (WXFontList) 0);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
WXFontType wxFont::GetFontType(WXDisplay* display) const
|
||||
{
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
|
||||
#if wxUSE_RENDER_TABLE
|
||||
return Ok() ? GetRenderTable(display) : NULL;
|
||||
#else
|
||||
return Ok() ? GetFontList(1.0, display) : NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
WXFontType wxFont::GetFontTypeC(WXDisplay* display) const
|
||||
{
|
||||
#if wxUSE_RENDER_TABLE
|
||||
return Ok() ? GetRenderTable(display) : NULL;
|
||||
#else
|
||||
return Ok() ? XmFontListCopy( (XmFontList)GetFontList(1.0, display) ) : NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*static*/ WXString wxFont::GetFontTag()
|
||||
{
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
|
||||
#if wxUSE_RENDER_TABLE
|
||||
return (WXString)XmNrenderTable;
|
||||
#else
|
||||
return (WXString)XmNfontList;
|
||||
|
@@ -95,13 +95,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
m_backgroundColour = * wxWHITE;
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
WXFontType fontType = (WXFontType)NULL;
|
||||
|
||||
if( m_font.Ok() )
|
||||
{
|
||||
fontType = m_font.GetFontType(XtDisplay(parentWidget));
|
||||
}
|
||||
Display* dpy = XtDisplay(parentWidget);
|
||||
|
||||
Arg args[4];
|
||||
int count = 0;
|
||||
@@ -111,9 +105,10 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
( m_windowStyle & wxLB_EXTENDED ) ? XmEXTENDED_SELECT :
|
||||
XmBROWSE_SELECT );
|
||||
++count;
|
||||
if( fontType )
|
||||
if( m_font.Ok() )
|
||||
{
|
||||
XtSetArg( args[count], (String)wxFont::GetFontTag(), fontType );
|
||||
XtSetArg( args[count],
|
||||
(String)wxFont::GetFontTag(), m_font.GetFontTypeC(dpy) );
|
||||
++count;
|
||||
}
|
||||
if( m_windowStyle & wxLB_ALWAYS_SB )
|
||||
|
@@ -661,15 +661,15 @@ void wxMenu::ChangeFont(bool keepOriginalSize)
|
||||
if (!m_font.Ok() || !m_menuWidget)
|
||||
return;
|
||||
|
||||
WXFontType fontType = m_font.GetFontType(XtDisplay((Widget) m_menuWidget));
|
||||
Display* dpy = XtDisplay((Widget) m_menuWidget);
|
||||
|
||||
XtVaSetValues ((Widget) m_menuWidget,
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
|
||||
NULL);
|
||||
if (m_buttonWidget)
|
||||
{
|
||||
XtVaSetValues ((Widget) m_buttonWidget,
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -681,7 +681,7 @@ void wxMenu::ChangeFont(bool keepOriginalSize)
|
||||
if (m_menuWidget && item->GetButtonWidget() && m_font.Ok())
|
||||
{
|
||||
XtVaSetValues ((Widget) item->GetButtonWidget(),
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
|
||||
NULL);
|
||||
}
|
||||
if (item->GetSubMenu())
|
||||
|
@@ -73,6 +73,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
m_majorDim = majorDim ;
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
Display* dpy = XtDisplay(parentWidget);
|
||||
|
||||
m_mainWidget = XtVaCreateWidget ("radioboxframe",
|
||||
xmFrameWidgetClass, parentWidget,
|
||||
@@ -82,8 +83,6 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
|
||||
wxString label1(wxStripMenuCodes(title));
|
||||
|
||||
WXFontType fontType = m_font.GetFontType(XtDisplay(parentWidget));
|
||||
|
||||
if (!label1.empty())
|
||||
{
|
||||
wxXmString text(label1);
|
||||
@@ -94,10 +93,9 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
: xmLabelGadgetClass,
|
||||
(Widget)m_mainWidget,
|
||||
#else
|
||||
xmLabelWidgetClass,
|
||||
(Widget)m_mainWidget,
|
||||
xmLabelWidgetClass, (Widget)m_mainWidget,
|
||||
#endif
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
|
||||
XmNlabelString, text(),
|
||||
// XmNframeChildType is not in Motif 1.2, nor in Lesstif,
|
||||
// if it was compiled with 1.2 compatibility
|
||||
@@ -107,8 +105,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
#else
|
||||
XmNchildType, XmFRAME_TITLE_CHILD,
|
||||
#endif
|
||||
XmNchildVerticalAlignment,
|
||||
XmALIGNMENT_CENTER,
|
||||
XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@@ -132,13 +129,14 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
{
|
||||
wxString str(wxStripMenuCodes(choices[i]));
|
||||
m_radioButtonLabels.push_back(str);
|
||||
Widget radioItem = XtVaCreateManagedWidget (wxConstCast(str.c_str(), char),
|
||||
Widget radioItem = XtVaCreateManagedWidget (
|
||||
wxConstCast(str.c_str(), char),
|
||||
#if wxUSE_GADGETS
|
||||
xmToggleButtonGadgetClass, radioBoxWidget,
|
||||
#else
|
||||
xmToggleButtonWidgetClass, radioBoxWidget,
|
||||
#endif
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
|
||||
NULL);
|
||||
m_radioButtons.push_back((WXWidget)radioItem);
|
||||
XtAddCallback (radioItem, XmNvalueChangedCallback,
|
||||
@@ -356,16 +354,13 @@ void wxRadioBox::ChangeFont(bool keepOriginalSize)
|
||||
{
|
||||
wxWindow::ChangeFont(keepOriginalSize);
|
||||
|
||||
WXFontType fontType =
|
||||
m_font.GetFontType(XtDisplay((Widget) GetTopWidget()));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m_noItems; i++)
|
||||
{
|
||||
WXWidget radioButton = m_radioButtons[i];
|
||||
|
||||
XtVaSetValues ((Widget) radioButton,
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay((Widget) GetTopWidget())),
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
@@ -56,20 +56,19 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
|
||||
return false;
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
Display* dpy = XtDisplay(parentWidget);
|
||||
|
||||
wxString label1(wxStripMenuCodes(label));
|
||||
|
||||
wxXmString text( label1 );
|
||||
|
||||
WXFontType fontType = m_font.GetFontType(XtDisplay(parentWidget));
|
||||
|
||||
Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle",
|
||||
#if wxUSE_GADGETS
|
||||
xmToggleButtonGadgetClass, parentWidget,
|
||||
#else
|
||||
xmToggleButtonWidgetClass, parentWidget,
|
||||
#endif
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
|
||||
XmNlabelString, text(),
|
||||
XmNfillOnSelect, True,
|
||||
XmNindicatorType, XmONE_OF_MANY, // diamond-shape
|
||||
|
@@ -108,13 +108,13 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
||||
bool hasLabel = (!label.IsNull() && !label.IsEmpty()) ;
|
||||
if (hasLabel)
|
||||
{
|
||||
WXFontType fontType = m_font.GetFontType( XtDisplay( parentWidget ) );
|
||||
wxString label1(wxStripMenuCodes(label));
|
||||
wxXmString text(label1);
|
||||
Display* dpy = XtDisplay( parentWidget );
|
||||
|
||||
m_labelWidget = (WXWidget) XtVaCreateManagedWidget ("staticboxlabel",
|
||||
xmLabelWidgetClass, (Widget)m_mainWidget,
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(dpy),
|
||||
XmNlabelString, text(),
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 )
|
||||
XmNframeChildType, XmFRAME_TITLE_CHILD,
|
||||
|
@@ -51,15 +51,14 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
|
||||
Widget borderWidget =
|
||||
(Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style );
|
||||
wxXmString text( wxStripMenuCodes( label ) );
|
||||
WXFontType fontType = m_font.GetFontType(XtDisplay(parentWidget));
|
||||
|
||||
m_labelWidget = XtVaCreateManagedWidget (wxConstCast(name.c_str(), char),
|
||||
m_labelWidget =
|
||||
XtVaCreateManagedWidget (wxConstCast(name.c_str(), char),
|
||||
xmLabelWidgetClass,
|
||||
borderWidget ? borderWidget : parentWidget,
|
||||
wxFont::GetFontTag(), fontType,
|
||||
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)),
|
||||
XmNlabelString, text(),
|
||||
XmNalignment,
|
||||
((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
|
||||
XmNalignment, ((style & wxALIGN_RIGHT) ? XmALIGNMENT_END :
|
||||
((style & wxALIGN_CENTRE) ? XmALIGNMENT_CENTER :
|
||||
XmALIGNMENT_BEGINNING)),
|
||||
NULL);
|
||||
|
@@ -929,7 +929,7 @@ extern void wxDoChangeFont(WXWidget widget, wxFont& font)
|
||||
#if !wxCHECK_LESSTIF() || wxCHECK_LESSTIF_VERSION( 0, 93 )
|
||||
Widget w = (Widget)widget;
|
||||
XtVaSetValues( w,
|
||||
wxFont::GetFontTag(), font.GetFontType( XtDisplay(w) ),
|
||||
wxFont::GetFontTag(), font.GetFontTypeC( XtDisplay(w) ),
|
||||
NULL );
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user