Test for wxPen validity before testing for its style in wxGTK wxDC.

Calling wxPen::GetStyle() on an invalid pen resulted in an assert, breaking
the grid column drawing while reordering them, for example, because the code
in wxGrid uses wxDC::DrawRectangle() after calling SetPen(wxNullPen).

Fix this by testing for the pen validity first.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-06-03 10:35:49 +00:00
parent e612dec202
commit 1b46c6697f

View File

@@ -793,9 +793,8 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo
gdk_gc_set_ts_origin(gc, 0, 0); gdk_gc_set_ts_origin(gc, 0, 0);
} }
if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) if ( m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT )
{ {
#if 1
if ((m_pen.GetWidth() == 2) && (m_pen.GetCap() == wxCAP_ROUND) && if ((m_pen.GetWidth() == 2) && (m_pen.GetCap() == wxCAP_ROUND) &&
(m_pen.GetJoin() == wxJOIN_ROUND) && (m_pen.GetStyle() == wxPENSTYLE_SOLID)) (m_pen.GetJoin() == wxJOIN_ROUND) && (m_pen.GetStyle() == wxPENSTYLE_SOLID))
{ {
@@ -818,7 +817,6 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo
gdk_gc_set_line_attributes( m_penGC, 2, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND ); gdk_gc_set_line_attributes( m_penGC, 2, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND );
} }
else else
#endif
{ {
// Just use X11 for other cases // Just use X11 for other cases
gdk_draw_rectangle( m_gdkwindow, m_penGC, FALSE, xx, yy, ww-1, hh-1 ); gdk_draw_rectangle( m_gdkwindow, m_penGC, FALSE, xx, yy, ww-1, hh-1 );