Qt 5.6.0 a workaround for using QML in some cases to construct Webview/webengineview errors

Source: Internet
Author: User
Qt 5.6.0 A workaround for using QML in some cases to construct Webview/webengineview errors

A strange phenomenon that I ran into when I was using Qtquick. There are many people on the internet, but there is no corresponding solution. I was lucky to find a way to solve the problem. Although it is impossible to determine the root cause of the problem, it may be possible to help others or later in the first record. Situation Description

On my machine, I was confronted with a situation in which the program would have an error when using WebView or Webengineview in QML. The specific content of the error is that memory cannot be accessed:

Exception thrown at 0x00007ffa4e9b6dd6 (Qt5Gui.dll) in xxx.exe:0xc0000005:access violation reading location 0x0000000000 000008.

In debug mode, you can see that the stack is:

qt5guid.dll! Qscopedpointer<qobjectdata,qscopedpointerdeleter<qobjectdata>::d ATA () line 135    C + +
qt5guid.dll!qgetptrhelper<qscopedpointer<qobjectdata,qscopedpointerdeleter<qobjectdata> > > ( Const qscopedpointer<qobjectdata,qscopedpointerdeleter<qobjectdata> > & P) line 1015    C + +
qt5guid.dll! Qopenglcontext::d _func () line 145   C + +
qt5guid.dll! Qopenglcontext::format () line 1094  C + +
qt5guid.dll! Qopenglcontext::isopengles () line 1244  C + +
... (No debug information available)

Starting with Qopenglcontext::isopengles (), the this pointer is empty. Workaround

My solution is simple, add a sentence before the program constructs qcoreapplication/qapplication:

Qcoreapplication::setattribute (qt::aa_shareopenglcontexts);
Discovery Process

I use Webengineview before using Qmlscene preview the effect, feel the effect can be considered in the program to use Webengineview.
But when I put Webengineview into the program, the program will give an error.
At first I thought it was a problem with the program compatibility. However, after careful investigation, it is found that the problem is not program compatibility.
At this point I think Qmlscene can be normal preview Webengineview, the problem is most likely in the configuration file above.
Find Qmlscene code (very simple), with the binary method to exclude irrelevant code, finally found the code:

Qcoreapplication::setattribute (qt::aa_shareopenglcontexts);
cause Analysis

The specific reason for this is that I still can't think of my present ability. There is little understanding of OpenGL in these things. If anyone knows, please instruct. official description of the Qt::aa_shareopenglcontexts property

Enables resource sharing between the OpenGL contexts used by classes like Qopenglwidget and Qquickwidget. This allows sharing OpenGL resources, like textures, between qopenglwidget instances. belong to different top-level WI Ndows. This value have been added in Qt 5.4. This attribute must was set before Q (Gui) application is constructed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.