Support #7346
openUsing WStandardItemModel and getting error: Wt internal error: Unexpected token: '-'
0%
Description
Hi! I'm updating a WStandardItemModel with about 270 values every 50 ms. After about 24 hours the application stopps and the browser opens a message box that says: "Wt internal error: Unexpected token: '-'
"
I'm asking myself if I'm using the WStandardItemModel correct or if I'm doing something wrong.
It would be great to get a little bit support or a good example from github.
Test environment: wt-4.1.1, lastest chrome, 8 browser windows
The following lines explain my method:
- The
Server::run()
updates each session by callingWt::WServer::instance()->post(...)
, this callsClientWidget::updateData()
- The
ClientWidget::updateData()
gets the data from Server::instance(), updates theWStandardItemModel
and callstriggerUpdate()
These two steps work fine, if I just update a Wtext on the widget.
The following steps are done to handle the model:
Init model:
void initModel(const std::vector<std::string>& header)
{
model->insertColumns(model->columnCount(), header.size());
auto colCount = 0;
for(auto& head : header) {
model->setHeaderData(colCount++, Wt::WString(head));
}
for(int row = 0; row < model->rowCount(); ++row) {
for(int col = 0; col < model->columnCount(); ++col) {
model->item(row, col)->setFlags(Wt::ItemFlag::Selectable);
}
}
}
Insert new rows to the model:
auto valueIdItem = std::make_unique<Wt::WStandardItem>(data.getId());
auto valueNameItem = std::make_unique<Wt::WStandardItem>(data.getName());
auto valueDataItem = std::make_unique<Wt::WStandardItem>("0");
idToRow[data.getId()] = rowMaxCounter++; // just something to map internal IDs an the row
std::vector<std::unique_ptr<Wt::WStandardItem> > v;
v.push_back(std::move(valueIdItem));
v.push_back(std::move(valueNameItem));
v.push_back(std::move(valueDataItem));
model->insertRow(idToRow[data.getId()], std::move(v));
Update model data:
model->setData(rowId, 2, data.getValue(), Wt::ItemDataRole::Display); // data.getValue() returns a std::string with new content
Updated by Roel Standaert almost 5 years ago
- Status changed from New to Feedback
- Target version deleted (
4.2.1)
I don't immediately see anything wrong here. The error you're getting seems to happen on the client side, perhaps something going wrong with the JavaScript being sent to the client. However, since you're using post()
it shouldn't normally be a concurrency issue. Could you perhaps create a more extended standalone example that exhibits the same behavior? I wouldn't know where to start looking from this.
Updated by Fabian V almost 5 years ago
Roel Standaert wrote:
I don't immediately see anything wrong here. The error you're getting seems to happen on the client side, perhaps something going wrong with the JavaScript being sent to the client. However, since you're using
post()
it shouldn't normally be a concurrency issue. Could you perhaps create a more extended standalone example that exhibits the same behavior? I wouldn't know where to start looking from this.
I'm sorry but we are not using this framework anymore. But the main code is the one above. Maybe 200 values in a 100ms interval is too much.