Critical/Fatal error detection

  • Good Day All,

    I am using the following code to open and display html content.

    @void MyClass::playHtml(QString filePath, int w, int h) {
    QUrl url = QUrl::fromLocalFile(filePath);

    mWidget = new QWebView(this);
    mWidget->page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    mWidget->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
    mWidget->setGeometry(0, 0, width(), height());

     float h_scale = (float) height() / h;
     float w_scale = (float) width() / w;
     float zoom = 1.0;
     if (h_scale < w_scale) {
         zoom = h_scale;
     } else {
         zoom = w_scale;


    This is inside the MyClass, which sets its own geometry and this function scales the QWebView appropriately to maintain aspect ratio. The Deletion for the mWidget(QWebView pointer) is being called when the MyClass object is deleted. Here is the process of how it is called.
    1.) MyClass is instantiated as "mclass".
    2.) after instantiation, the playHtml method above is called on mclass object
    3.) the playHtml method above takes the full path to an html file that resides in a self-contained folder, the w/h are the pre-determined dimensions of the html content are used in scaling
    4.) after about 25 seconds, the mclass object is deleted
    4a.) during those 25 seconds the playHtml method scales the html content appropriately, and loads the html file. A lot of javascript happens for animation, etc.
    5.) after the deletion another instantiation of MyClass occurs and the process is repeated

    this process can be repeated literally 3000 times in a day, one after another. Neither the cpu nor ram are taxed during this time. The only thing I left out of the process above is the logging. I installed a MessageHandler to log the qDebug and other messages.

    Here is what I am seeing in the logs after the above process runs for a while (anywhere from a couple of hours to a few days).

    A bunch of these per instance of “MyClass"
    @CRITICAL: QWindowsBackingStore::flush: GetDC failed ()@

    followed by a bunch of these per instance of “MyClass"

    @CRITICAL: QWindowsBackingStore::flush: BitBlt failed ()@

    Followed shortly by a crash.

    In the event viewer, I get the crash “Error” message. It is always in one of these faulting modules MSVCR100.dll or one of the Qt5Webkit or Qt5WebkitWidget dlls.

    I am not specifically drawing anything. I relying on the QWebView to do that -- both for drawing itself and the content it contains. It does it well except when the above starts occurring. Nothing else is running on the machine except the software.

    How would one go about detecting errors like this? At this point, I don’t know anything about them until they get to the log. I would like to detect and deal with them before that time but am unsure how. As a side note, I would like to take this opportunity to learn more about error detection in general for Qt and C++. Primarily, how do I detect errors like this that seem to be occurring further up the food chain. I fear I have been spoiled by the stack traces provided by Java/C#.

    Environment information:
    Windows 7 professional 64bit
    Qt 5.2.1 (32 bit)
    Compiled using VS2010



Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.