wxGridCellAttr::Clone() access violation Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ebyrob
Knows some wx things
Knows some wx things
Posts: 27
Joined: Wed Sep 28, 2016 8:27 pm

wxGridCellAttr::Clone() access violation

Post 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)
Operating System: Windows 1-, 64-bit / macOS 13.4.1, Apple M1
Compiler: Visual Studio 2019 / Xcode 14.3.1
wxWidgets version: 3.1.0 / 3.2.2
ebyrob
Knows some wx things
Knows some wx things
Posts: 27
Joined: Wed Sep 28, 2016 8:27 pm

Re: wxGridCellAttr::Clone() access violation

Post by ebyrob »

Right, so GetAttr() is returning NULL...

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

So, ignore this I guess.
Operating System: Windows 1-, 64-bit / macOS 13.4.1, Apple M1
Compiler: Visual Studio 2019 / Xcode 14.3.1
wxWidgets version: 3.1.0 / 3.2.2
Post Reply