Project

General

Profile

Actions

Bug #12424

open

WVideo throw WAbstractMedia: error parsing when working with large mvc table elements.

Added by Apivan Tuntakurn 2 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
02/16/2024
Due date:
% Done:

0%

Estimated time:

Description

The "WVideo" throws an exception when placed with large table elements.

The exception is thrown here:

void WAbstractMedia::setFormData(const FormData& formData)
{
....
    } else
      throw WException("WAbstractMedia: error parsing: "
                       + formData.values[0]);
  }
}

I've also noticed that the Emweb website's Wt widget gallery also shows it sending the "undefined" parameters on the MVC table view page. The "undefined" issue originates from Wt.js. I've made a pull request to solve this issue. Please have a look when you have a time.

Here is the reproducible code.
When the number table elements is high enough tableView->setModel(std::make_unique(10, 15)); It reproduces this issue.

class VirtualModel : public Wt::WAbstractTableModel
{
public:
  VirtualModel(int rows, int columns)
    : rows_(rows),
    columns_(columns)
  { }

  int rowCount(const Wt::WModelIndex& parent = Wt::WModelIndex()) const override
  {
    if (!parent.isValid())
      return rows_;
    else
      return 0;
  }

  int columnCount(const Wt::WModelIndex& parent = Wt::WModelIndex()) const override
  {
    if (!parent.isValid())
      return columns_;
    else
      return 0;
  }

  Wt::cpp17::any data(const Wt::WModelIndex& index, ItemDataRole role = Wt::ItemDataRole::Display) const override
  {

    if (role == Wt::ItemDataRole::Display)
    {
        if (index.column() == 0)
        {

            return Wt::WString("Row {1}").arg(index.row());
        }
        else
        {
                 return Wt::WString("Item row {1}, col {2}")
                .arg(index.row()).arg(index.column());
        }
    }
    else
    {
      return {};
    }
  }

  Wt::cpp17::any headerData(int section,
    Wt::Orientation orientation = Wt::Orientation::Horizontal,
    ItemDataRole role = Wt::ItemDataRole::Display) const override
  {
    if (orientation == Wt::Orientation::Horizontal) {
      if (role == Wt::ItemDataRole::Display)
      {
        return Wt::WString("Column {1}").arg(section);
      }
      else
      {
        return {};
      }
    }
    else
      return {};
  }

private:
  int rows_, columns_;
};

  auto theme = std::make_shared<Wt::WBootstrapTheme>();
  theme->setVersion(Wt::BootstrapVersion::v3);
  setTheme(theme);


  setTitle("TableBenchmarkingApp");
  root()->setPadding(Wt::WLength(30), Wt::Side::Left);
  {
    auto tableView = root()->addNew<Wt::WTableView>();
    tableView->setModel(std::make_unique<VirtualModel>(10, 15));

  }






  // Define media source locations
  std::string mp4Video = "https://www.webtoolkit.eu/videos/sintel_trailer.mp4";
  std::string ogvVideo = "https://www.webtoolkit.eu/videos/sintel_trailer.ogv";

  // Define poster image location
  std::string poster = "pics/sintel_trailer.jpg";

  auto tp = std::make_unique<Wt::WTemplate>();
  tp->setTemplateText(R"HTML(
<div >

         ${BigVideo}

</div>


)HTML");


  auto video = tp->bindWidget("BigVideo", std::make_unique<Wt::WVideo>());

  video->addSource(Wt::WLink(mp4Video));
  video->addSource(Wt::WLink(ogvVideo));
  video->setPoster(poster);
  video->setAlternativeContent(std::make_unique<Wt::WImage>(Wt::WLink(poster)));
  video->resize(640, 360);


  root()->addWidget(std::move(tp));



Files

clipboard-202402161433-ol7sa.png (369 KB) clipboard-202402161433-ol7sa.png Apivan Tuntakurn, 02/16/2024 08:33 AM

No data to display

Actions

Also available in: Atom PDF