From: Julian Smart Date: Sun, 1 Jun 2003 12:51:06 +0000 (+0000) Subject: Applied patch [ 746203 ] xwGrid::SetTable may be called multiple times X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/233a54f6af572d58617341bab4778ff261d3f723 Applied patch [ 746203 ] xwGrid::SetTable may be called multiple times git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20799 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index ef6fddb7e0..78a7a2612e 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -3913,16 +3913,18 @@ bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership, { if ( m_created ) { - // RD: Actually, this should probably be allowed. I think it would be - // nice to be able to switch multiple Tables in and out of a single - // View at runtime. Is there anything in the implementation that - // would prevent this? - - // At least, you now have to cope with m_selection - wxFAIL_MSG( wxT("wxGrid::CreateGrid or wxGrid::SetTable called more than once") ); - return FALSE; - } - else + if (m_ownTable) + delete m_table; + delete m_selection; + + // stop all processing + m_table=0; + m_selection=0; + m_created = FALSE; + m_numRows=0; + m_numCols=0; + } + if (table) { m_numRows = table->GetNumberRows(); m_numCols = table->GetNumberCols();