[wx-dev] pb with wxgrid::Create on wxmac 2.9
Riccardo Cohen
rcohen at articque.com
Thu Feb 21 04:55:13 PST 2008
ok I'll try to do that next week
Vadim Zeitlin wrote:
> On Tue, 19 Feb 2008 15:29:22 +0100 Riccardo Cohen <rcohen at articque.com> wrote:
>
> RC> bool wxGrid::Create(wxWindow *parent, wxWindowID id,
> RC> const wxPoint& pos, const wxSize& size,
> RC> long style, const wxString& name)
> RC> {
> RC> if (!wxScrolledWindow::Create(parent, id, pos, size,
> RC> style | wxWANTS_CHARS, name))
> RC> return false;
> RC>
> RC> m_colMinWidths = wxLongToLongHashMap(GRID_HASH_SIZE);
> RC> m_rowMinHeights = wxLongToLongHashMap(GRID_HASH_SIZE);
> RC>
> RC> Create();
> RC>
> RC> The wxScrolledWindow::Create() function calls a Refresh, which needs
> RC> m_cornerLabelWin, but this member is only initialized in
> RC> wxGrid::Create() called after the scrolled window creation.
> RC>
> RC> I tried to add a test in generic/grid.cpp :
> RC>
> RC> --- grid.cpp (revision 51909)
> RC> +++ grid.cpp (working copy)
> RC> @@ -6893,7 +6893,7 @@
> RC> m_gridWin->Refresh(eraseb, &anotherrect);
> RC> }
> RC> }
> RC> - else
> RC> + else if (m_cornerLabelWin!=NULL)
> RC> {
> RC> m_cornerLabelWin->Refresh(eraseb, NULL);
> RC> m_colLabelWin->Refresh(eraseb, NULL);
> RC>
> RC>
> RC> and this seems to be enough to stop the crash, but I'm not sure it is
> RC> the good correction. What is the best ?
>
> I think this is the right fix as I don't see how can we prevent Refresh()
> from being called during the creation and it shouldn't crash if it's called
> anyhow.
>
> However I don't think this is all you need because m_cornerLabelWin is not
> even initialized to NULL when you use non-default wxGrid ctor. So we also
> need to refactor the default ctor to call some InitVars() (usually this
> would be called Init() but it's already taken in wxGrid...) which would set
> all these variables to NULL.
>
> Also, there seems to be m_created variable which is meant to be tested in
> the situations like this. But, again, it's not initialized (and this time
> by neither ctor). So it should be initialized to in this InitVars() and
> Refresh() should probably just return immediately if !m_created.
>
> Could you please make a patch doing this, test it with your code and
> submit if it works?
>
> TIA,
> VZ
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-dev-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-dev-help at lists.wxwidgets.org
>
>
--
Très cordialement,
Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av Général de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49
More information about the wx-dev
mailing list