Search code examples
c++qtaccess-violationqwebview

Specific websites throwing an exception in QWebView


While running my code I am getting a Write Access Violation Exception when it tries to use QWebView:

Minimal compilable code for reproducing the error

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKitWidgets/QWebView>
#include <QUrl>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QWebView *wv = new QWebView(this);
    wv->load(QUrl("http://steamcommunity.com/"));
    setCentralWidget(wv);

}

MainWindow::~MainWindow()
{
    delete ui;
}

The pro file also includes webkitwidgets and network:

QT       += core gui webkitwidgets network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyApp
TEMPLATE = app
SOURCES += main.cpp\
        mainwindow.cpp
HEADERS  += mainwindow.h
FORMS    += mainwindow.ui

Error Hints

The error I get looks like this:

ASSERTION FAILED: leftSide->category() != CalcOther && rightSide->category() != CalcOther
css\CSSCalculationValue.cpp(290) : WebCore::CSSCalcBinaryOperation::create
1   0354A5B7
2   02E58E41
3   02E59520
 ...

I can't provide a stack trace because the error is in one of the Qt files, but here is the disassembly: disassembly

The error only occurs on specific webpages (e.g. steamcommunity.com) but not others. Is it possible that some sites just break Qt's API?

  • compiler: MSVC2013 x86
  • Qt version: Qt 5.5.0

Solution

  • Turns out that this error is actually a Qt bug. Its status can be viewed here: Qt Bug Report

    Using the new Qt WebEngine Widgets module worked great as a replacement for me.