]> git.saurik.com Git - wxWidgets.git/commitdiff
don't crash when using wxHtmlWidgetCell in wxHtmlListBox
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 5 Jun 2007 12:12:46 +0000 (12:12 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 5 Jun 2007 12:12:46 +0000 (12:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46330 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/html/htmlcell.cpp

index 4bed6f3f9c75b7d3a99b9d7671657fe73e1d05a2..feeabd00c3ee16323c9992a21ffa5594e9b2b83d 100644 (file)
@@ -1501,8 +1501,15 @@ void wxHtmlWidgetCell::Draw(wxDC& WXUNUSED(dc),
         c = c->GetParent();
     }
 
-    ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty);
-    m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy  - wxHTML_SCROLL_STEP * sty, m_Width, m_Height);
+    wxScrolledWindow *scrolwin =
+        wxDynamicCast(m_Wnd->GetParent(), wxScrolledWindow);
+    wxCHECK_RET( scrolwin,
+                 _T("widget cells can only be placed in wxHtmlWindow") );
+
+    scrolwin->GetViewStart(&stx, &sty);
+    m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx,
+                   absy  - wxHTML_SCROLL_STEP * sty,
+                   m_Width, m_Height);
 }