shared ptr error 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
gismo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 12, 2020 10:48 pm

shared ptr error

Post by gismo »

Using wxWidgets-3.1.3 on Windows 10
I'm getting a shared ptr error when charting data. I have one categorical dataset and 4 double datasets. I can run any 3 of the 4 double datasets together with the categorical dataset with no errors. When I try and run all for datasets together I get this error:

sharedptr.h(85):assert "m_ref!=_null" failed in operator().

I have a total of 10 double datasets I need to chart.

Here's my code:

Code: Select all

void AcornFrame::OnButtonGraphClick(wxCommandEvent& event)
{
    int j;
    wxWindow* ChartWindow = new wxWindow(Panel5,wxID_ANY,wxDefaultPosition, wxSize(1312,800));
	
       wxVector<wxString> labels;
    labels.push_back("0.5");
    labels.push_back("1.5");
    labels.push_back("2.5");
    labels.push_back("3.5");
    labels.push_back("4.5");
    labels.push_back("5.5");
	
	wxChartsCategoricalData::ptr chartData = wxChartsCategoricalData::make_shared(labels);
	double testno1;
	double testno2;
	double testno3;
	double testno4;
	
    // Add the first dataset
    wxVector<wxDouble> points1;
    for(j=1;j<7;++j)
    {
    testno1=stumpdbh10table[6][j];
    points1.push_back(testno1);
    }
    wxChartsDoubleDataset::ptr dataset1(new wxChartsDoubleDataset("MIXED HARDWOODS", points1));
    chartData->AddDataset(dataset1);

    // Add the second dataset
    wxVector<wxDouble> points2;
    for(j=1;j<7;++j)
    {
    testno2=stumpdbh10table[7][j];
    points2.push_back(testno2);
    }
    wxChartsDoubleDataset::ptr dataset2(new wxChartsDoubleDataset("CONIFER SPECIES", points2));
    chartData->AddDataset(dataset2);
	
    // Add the third dataset
        wxVector<wxDouble> points3;
    for(j=1;j<7;++j)
    {
    testno3=stumpdbh10table[8][j];
    points3.push_back(testno3);
    }
    wxChartsDoubleDataset::ptr dataset3(new wxChartsDoubleDataset("HICKORY SPECIES", points3));
    chartData->AddDataset(dataset3);

    // Add the fourth dataset
      wxVector<wxDouble> points4;
    for(j=1;j<7;++j)
    {
    testno4=stumpdbh10table[10][j];
    points4.push_back(testno4);
    }
    wxChartsDoubleDataset::ptr dataset4(new wxChartsDoubleDataset("GUM SPECIES", points4));
    chartData->AddDataset(dataset4);
    
    wxStackedColumnChartCtrl* stackedColumnChartCtrl = new wxStackedColumnChartCtrl(ChartWindow,
    wxID_ANY, chartData, wxPoint(0,0),wxSize(800,500));
}
Kvaz1r
Super wx Problem Solver
Super wx Problem Solver
Posts: 357
Joined: Tue Jun 07, 2016 1:07 pm

Re: shared ptr error

Post by Kvaz1r »

If the behaviour can be reproduce with the sample I would raise an issue in issue tracker of the chart library.
gismo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 12, 2020 10:48 pm

Re: shared ptr error

Post by gismo »

Kvaz1r the code I posted is essentially the sample code with very few changes but just to be sure I went back and compiled and ran the sample code cloning the 2 datasets in the sample into 4 and got the same error. This is from the wxCharts library which was last updated in 2019. I was only able to build it with mingw32 on windows 10 because another user had posted how to build it on the issues page. There hasn't been much activity on that issues page so I don't have much hope in the problem getting resolved there. I tried at first to build the library for wxFreecharts but that build also had an error with dynamic datasets. I'm wondering if these build issues are related to wxWidgets-3.1.3. I'm curious if anyone reading this is using a charting library with versions 3.1.3 or 3.05. Maybe the solution for me is to uninstall 3.1.3 and install 3.05. I would be happy to hear from anyone using a charting library on windows 10 with version 3.1.3 and not using visual studio.

Thanks
gismo
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 12, 2020 10:48 pm

Re: shared ptr error

Post by gismo »

So I did what Kvaz1r suggested and posted the problem on wxCharts issues page and got a response That solved the issue. I just needed to increase the number of datasets in the theme. The default theme was set to 3. Thanks Kvaz1r
Post Reply