QWebFrame-> toHtml()分段错误

时间:2015-08-20 09:49:38

标签: qt

我使用QT 5.4并遇到一些麻烦。有时,当我尝试使用myBrowser->page()->mainFrame()->toHtml();将加载的数据读取到QWebView时 - 我遇到了分段错误。怎么解决这个问题?

有回溯:

0   WTFCrash    C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xb9bfcf3   
1   WTF::fastRealloc(void*, unsigned int)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xb9b05e9   
2   WTF::StringImpl::reallocate(WTF::PassRefPtr<WTF::StringImpl>, unsigned int, wchar_t*&)  C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xb991d2e   
3   void WTF::StringBuilder::reallocateBuffer<wchar_t>(unsigned int)    C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xb996e04   
4   wchar_t* WTF::StringBuilder::appendUninitializedSlow<wchar_t>(unsigned int) C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xbb17957   
5   WTF::StringBuilder::append(unsigned char const*, unsigned int)  C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xb99720a   
6   WebCore::MarkupAccumulator::appendCharactersReplacingEntities(WTF::StringBuilder&, WTF::String const&, unsigned int, unsigned int, WebCore::EntityMask) C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1974fe   
7   WebCore::MarkupAccumulator::appendAttributeValue(WTF::StringBuilder&, WTF::String const&, bool) C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa19795d   
8   WebCore::MarkupAccumulator::appendAttribute(WTF::StringBuilder&, WebCore::Element*, WebCore::Attribute const&, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e458b   
9   WebCore::MarkupAccumulator::appendElement(WTF::StringBuilder&, WebCore::Element*, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>>*)    C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e4768   
10  WebCore::MarkupAccumulator::appendStartMarkup(WTF::StringBuilder&, WebCore::Node const*, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>>*) C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1c9672   
11  WebCore::MarkupAccumulator::appendStartTag(WebCore::Node*, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e0792   
12  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e3a01   
13  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
14  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
15  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
16  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
17  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
18  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
19  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
20  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
21  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
22  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
23  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
24  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
25  WebCore::MarkupAccumulator::serializeNodesWithNamespaces(WebCore::Node*, WebCore::Node*, WebCore::EChildrenOnly, WTF::HashMap<WTF::AtomicStringImpl*, WTF::AtomicStringImpl*, WTF::PtrHash<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>, WTF::HashTraits<WTF::AtomicStringImpl*>> const*, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*)   C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e38d0   
26  WebCore::createMarkup(WebCore::Node const*, WebCore::EChildrenOnly, WTF::Vector<WebCore::Node*, 0u, WTF::CrashOnOverflow>*, WebCore::EAbsoluteURLs, WTF::Vector<WebCore::QualifiedName, 0u, WTF::CrashOnOverflow>*, WebCore::EFragmentSerialization)    C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0xa1e3bb5   
27  QWebFrameAdapter::toHtml() const    C:\QT\5.4\mingw491_32\bin\Qt5WebKitd.dll        0x9cf0f10   
28  QWebFrame::toHtml       268 0xe404824   
29  VBSearshMachine::movingToNextPage   VBSearshMachine.cpp 200 0x40e59e    
30  VBSearshMachine::qt_static_metacall moc_VBSearshMachine.cpp 233 0x42ff0b    
31  QMetaObject::activate       3716    0x6b95a0c0  
32  QMetaObject::activate       3582    0x6b959a1a  
33  QSingleShotTimer::timeout       122 0x6b95e452  
34  QSingleShotTimer::timerEvent        318 0x6b95de0b  
35  QObject::event      1226    0x6b9543ec  
36  QApplicationPrivate::notify_helper      3720    0xf08f4dd   
37  QApplication::notify        3164    0xf08ceb0   
38  QCoreApplication::notifyInternal        935 0x6b92ee90  
39  QCoreApplication::sendEvent     228 0x6b9d4e9f  
40  QEventDispatcherWin32Private::sendTimerEvent        615 0x6b97e0c5  
41  qt_internal_proc(HWND__*, unsigned int, unsigned int, long)*16      417 0x6b97d682  
42  USER32!CallNextHookEx   C:\Windows\SYSTEM32\user32.dll      0x771d8e71  
43  USER32!CallNextHookEx   C:\Windows\SYSTEM32\user32.dll      0x771d90d1  
44  USER32!GetMessageW  C:\Windows\SYSTEM32\user32.dll      0x771da66f  
45  USER32!DispatchMessageW C:\Windows\SYSTEM32\user32.dll      0x771da6e0  
46  QEventDispatcherWin32::processEvents        806 0x6b97ed24  
47  QWindowsGuiEventDispatcher::processEvents       73  0x2ccce774  
48  QEventLoop::processEvents       128 0x6b92cf14  
49  QEventLoop::exec        204 0x6b92d1a7  
50  QCoreApplication::exec      1188    0x6b92f4d3  
51  QGuiApplication::exec       1507    0x1326bac   
52  QApplication::exec      2956    0xf08c7ef   
53  qMain   main.cpp    108 0x401ec9    
54  WinMain*16      112 0x434a38    
55  main            0x46069d    

1 个答案:

答案 0 :(得分:0)

您在该表达式中的某处取消引用空指针。在使用它们之前,必须检查它们是否为空:

Q_ASSERT(myBrowser);
if (myBrowser->page() && myBrowser->page()->mainFrame()) {
  auto html = myBrowser->page()->mainFrame()->toHtml();
  ...
}