In a c++ wxwidget application, I have this custom class:

#ifndef GRIDSTRINGTABLEGAMES_H
#define GRIDSTRINGTABLEGAMES_H

#include “Game.h”
#include “CompletionStatus.h”

#include <wx/grid.h>
#include <wx/arrstr.h>

class GridStringTableGames : public wxGridStringTable
{
public:
GridStringTableGames(int cols);
GridStringTableGames(const std::vector<Game>& g, int cols);
virtual ~GridStringTableGames();
int GetNumberRows() override;
int GetNumberCols() override;
wxString GetValue(int row, int col) override;
void SetValue(int row, int col, const wxString& value) override;
wxString GetColLabelValue(int col) override;
std::vector<Game> GetGames();
void SetGames(std::vector<Game> games);
Game GetGame(int position);
void SetGame(int position, Game game);

private:
wxString GetCompletionStatusString(CompletionStatus status);
CompletionStatus GetCompletionStatusFromString(wxString status);
int GetIntFromString(wxString value);

std::vector<Game> games;
int columns;
};

#endif // GRIDSTRINGTABLEGAMES_H

#include “GridStringTableGames.h”

GridStringTableGames::GridStringTableGames(int cols) : GridStringTableGames(std::vector<Game>(), cols)
{
}

GridStringTableGames::GridStringTableGames(const std::vector<Game>& g, int cols) : games(g), columns(cols)
{
}

GridStringTableGames::~GridStringTableGames()
{
}

int GridStringTableGames::GetNumberRows()
{
return games.size();
}

int GridStringTableGames::GetNumberCols()
{
return columns;
}

wxString GridStringTableGames::GetValue(int row, int col)
{
switch (col)
{
case 0: return games[row].GetName();
case 1: return games[row].GetSystem();
case 2: return games[row].GetGenre();
case 3: return GetCompletionStatusString(games[row].GetCompletetionStatus());
case 4: return wxString(std::to_string(games[row].GetFinishYear()));
case 5: return wxString(std::to_string(games[row].GetStartYear()));
default: return “”;
}
}

void GridStringTableGames::SetValue(int row, int col, const wxString& value)
{
switch (col)
{
case 0: games[row].SetName(value); break;
case 1: games[row].SetSystem(value); break;
case 2: games[row].SetGenre(value); break;
case 3: games[row].SetCompletetionStatus(GetCompletionStatusFromString(value)); break;
case 4: games[row].SetFinishYear(GetIntFromString(value)); break;
case 5: games[row].SetStartYear(GetIntFromString(value)); break;
}
}

wxString GridStringTableGames::GetColLabelValue(int col)
{
switch (col)
{
case 0: return “Name”;
case 1: return “System”;
case 2: return “Genre”;
case 3: return “Completion Status”;
case 4: return “Finish Year”;
case 5: return “Start Year”;
default: return “”;
}
}

void GridStringTableGames::SetGames(std::vector<Game> g)
{
games = g;
}

std::vector<Game> GridStringTableGames::GetGames()
{
return games;
}

Game GridStringTableGames::GetGame(int position)
{
return games[position];
}

void GridStringTableGames::SetGame(int position, Game game)
{
games[position] = game;
}

wxString GridStringTableGames::GetCompletionStatusString(CompletionStatus status)
{
switch (status)
{
case CompletionStatus::Unplayed: return “Unplayed”;
case CompletionStatus::Playing: return “Playing”;
case CompletionStatus::Completed: return “Completed”;
case CompletionStatus::Played: return “Played”;
case CompletionStatus::OnHold: return “OnHold”;
case CompletionStatus::Dropped: return “Dropped”;
default: return “”;
}
}

CompletionStatus GridStringTableGames::GetCompletionStatusFromString(wxString status)
{
if (status == “Unplayed”)
{
return CompletionStatus::Unplayed;
}
else if (status == “Playing”)
{
return CompletionStatus::Playing;
}
else if (status == “Completed”)
{
return CompletionStatus::Completed;
}
else if (status == “Played”)
{
return CompletionStatus::Played;
}
else if (status == “OnHold”)
{
return CompletionStatus::OnHold;
}
else if (status == “Dropped”)
{
return CompletionStatus::Dropped;
}
else
{
return CompletionStatus::Unplayed;
}
}

int GridStringTableGames::GetIntFromString(wxString value)
{
long l = 0;
value.ToLong(&l);

return static_cast<int>(l);
}


and it is giving me an error in the frame, when assigning the table:

gridGames->SetTable(table, true);

the error it gives is Process terminated with status -1073740940 (0 minute(s), 1 second(s))

and debugging shows an error inside the OnPaint method:

void wxGrid::DrawRowLabel( wxDC& dc, int row )
{
if ( GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0 )
return;

wxGridCellAttrProvider * const
attrProvider = m_table ? m_table->GetAttrProvider() : NULL;

// notice that an explicit static_cast is needed to avoid a compilation
// error with VC7.1 which, for some reason, tries to instantiate (abstract)
// wxGridRowHeaderRenderer class without it
const wxGridRowHeaderRenderer&
rend = attrProvider ? attrProvider->GetRowHeaderRenderer(row) : static_cast<const wxGridRowHeaderRenderer&>(gs_defaultHeaderRenderers.rowRenderer); <-- ERROR
…
}

The call stack is this:

#0 0x6cfd76cb wxGrid::DrawRowLabel(this=0x29b5230, dc=…, row=0) (…/…/src/generic/grid.cpp:6740)
#1 0x6cfd7632 wxGrid::DrawRowLabels(this=0x29b5230, dc=…, rows=…) (…/…/src/generic/grid.cpp:6724)
#2 0x6cfc7afd wxGridRowLabelWindow::OnPaint(this=0x29b5a50) (…/…/src/generic/grid.cpp:2002)
#3 0x698c3946 wxAppConsoleBase::HandleEvent (this=0x2993490, handler=0x29b5a50, func=(void (wxEvtHandler::*)(wxEvtHandler * const, wxEvent &) (…/…/src/common/appbase.cpp:657)
#4 0x698c39c7 wxAppConsoleBase::CallEventHandler(this=0x2993490, handler=0x29b5a50, functor=…, event=…) (…/…/src/common/appbase.cpp:669)
#5 0x6999a7d2 wxEvtHandler::ProcessEventIfMatchesId(entry=…, handler=0x29b5a50, event=…) (…/…/src/common/event.cpp:1425)
#6 0x69999655 wxEventHashTable::HandleEvent(this=0x6d4bb8c0 <wxGridRowLabelWindow::sm_eventHashTable>, event=…, self=0x29b5a50) (…/…/src/common/event.cpp:1033)
#7 0x6999ac8a wxEvtHandler::TryHereOnly(this=0x29b5a50, event=…) (…/…/src/common/event.cpp:1622)



I tried:

1. CompletionStatus is properly implemented and initialized, since it is an enum and I am using it as enum, nothing else to it.
2. I checked and the only thing that could be out of range is the vector, can you check the code I posted to find if there is a wrong access?
3. wxGrid is properly parented and that was done by wxFormBuilder already.

I debugged the code and found an strange address that get repeated through different runs:

In the code that gives an error:

void wxGrid::DrawRowLabel( wxDC& dc, int row )
{
    if ( GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0 )
        return;

    wxGridCellAttrProvider * const
        attrProvider = m_table ? m_table->GetAttrProvider() : NULL;

    // notice that an explicit static_cast is needed to avoid a compilation
    // error with VC7.1 which, for some reason, tries to instantiate (abstract)
    // wxGridRowHeaderRenderer class without it
    const wxGridRowHeaderRenderer&
        rend = attrProvider ? attrProvider->GetRowHeaderRenderer(row)
                            : static_cast<const wxGridRowHeaderRenderer&>
                                (gs_defaultHeaderRenderers.rowRenderer);

rend makes it to crash, but attrProvider has the value:  0xfeeefeeefeeefeee, and attrProvider -> GetRowHeaderRenderer(row) gives the error "cannot access memory address at 0xfeeefeeefeeefeee", could it be some problem here?