Project

General

Profile

program ended with exit code: 9

Added by Mark Travis about 3 years ago

I can't figure this out. Maybe I'm not looking at it correctly.....

I'm reading in a CSV file into a WStandardItemModel.

I created a function to accept a shared_ptr to the WStandardItem model so I could extract one of the columns of numbers into a separate vector.

When the following code falls through to the "temp =" statement, the app crashes out of Xcode with no obvious trapped errors (which it is usually very good and specific about crash info)

i = 4 and column = 3 when the crash occurs.

double temp = 0.0;

   if (!cpp17::any(sourceSeries->data(i, column)).empty()) {
        if(cpp17::any(sourceSeries->data(i, column)).type() == typeid(Wt::WString)){
            temp = std::any_cast<double>(sourceSeries->data(i, column));
        }

Replies (3)

RE: program ended with exit code: 9 - Added by Korneel Dumon about 3 years ago

Hi Mark,

it seems obvious to me that this would not work: you know it is a WString, but you still cast it to a double.
Maybe I'm missing something?

BR,
Korneel

RE: program ended with exit code: 9 - Added by Mark Travis about 3 years ago

Yikes! You are correct. That's what I get for programming at midnight.

I redid it as follows. Unfortunately, I get the same weird behavior, except this time instead of the program ending with exit code '9', it just logs me out of WAuth and puts me at application start (logon page);

if (cpp17::any(sourceSeries->data(i, column)).empty()) {
if(cpp17::any(sourceSeries->data(i, column)).type() == typeid(Wt::WString)){
WString tempWstring = std::any_cast(sourceSeries->data(i, column)); <--- crashes as it tries to execute this line
std::string tempString = tempWstring.toUTF8();
temp = std::stod(tempString);
}
}

RE: program ended with exit code: 9 - Added by Mark Travis about 3 years ago

Just to update, I was pulling in a .csv that a potential user gave me. I should have looked at it first as it had things in it like this

10/27/17, , , 84, " 123,456,987 ", 0, " 99,948 "

So when I ran it through the tokenizer and stored it as ::any, it stored it as <???>

I added some cleanup code using the std::string::erase function to clean up the input file and everything works peachy now.

    (1-3/3)