wxGenericDirCtrl 错误 "wxTheFileIconsTable was nullptr"

wxGenericDirCtrl error "wxTheFileIconsTable was nullptr"

我开始使用 wxWidgets,在我想使用 "wxGenericDirCtrl" 之前一切似乎都运行良好。当我创建一个 wxGenericDirCtrl 的对象时,我的程序抛出一个异常,指出“wxTheFileIconsTable 是 nullptr”在 Release 模式和“this在 Debug 模式下为 nullptr"。我试过使用不同版本的 wxWidgets (3.0.4 - 3.1.3),但其中 none 有效。

Here's a screenshot of an error that I get

我在应用程序的构造函数中初始化框架,而不是在 OnInit 函数中进行。

我的代码是这样的:

App::App()
    : m_Frame(new Frame) { }

bool App::OnInit()
{
    m_Frame->Show();

    return true;
}

它应该是这样的:

bool App::OnInit()
{
    m_Frame = new Frame;
    m_Frame->Show();

    return true;
}