Page 1 of 1

wxGridCellAttr::Clone() access violation

Posted: Thu Aug 02, 2018 4:41 pm
by ebyrob
Running in the debugger with Visual Studio 2010, wxWidgets version 3.1.0.

I get an access violation cloning wxGridCellAttr.

Code: Select all

wxGrid* pGrid = new wxGrid(this, ID_GRID_MYCUSTOMID, wxDefaultPosition, wxSize(200,250));
pGrid->CreateGrid(1,12); // I always do this early to avoid problems with missing initialization

wxGridTableBase*        pBaseTable = pGrid->GetTable();
wxGridCellAttrProvider* pAttrProv  = pBaseTable->GetAttrProvider();
wxGridCellAttr*         pAttr1     = pBaseTable->GetAttr(0,0,wxGridCellAttr::Col);

// access violation occurs trying to clone default attributes:
wxGridCellAttr* pAttr3 = pAttr1->Clone();

 // another access violation trying to read from provider directly:
wxGridCellAttr*         pAttr2      = pAttrProv->GetAttr(0,0,wxGridCellAttr::Col);
I've got a temporary work-around creating wxGridCellAttr object from scratch, but it seems like I should be able to start with default attributes then change those to what I want. Also access violation on ->Clone() seems odd.

My only goal is to successfully call wxGrid's SetColAttr() function with over-ridden defaults. (setting attributes on every cell was too slow)

Re: wxGridCellAttr::Clone() access violation

Posted: Thu Aug 02, 2018 4:56 pm
by ebyrob
Right, so GetAttr() is returning NULL...

And low and behold, GetAttrProvider() is also returning NULL.

So, ignore this I guess.