QDomDocument Access violation writing location
今天犯了一个非常2的错误!
为了将面板参数保存起来,选择用QDomDocument构造Dom树,然后用doc.toString()方法返回符合xml格式的QString。如:
QString CutFaceFilter::saveParamsXML(CutFaceParams& para)
{
QDomDocument doc; QDomElement root = doc.createElement("parameters");
doc.appendChild(root); QDomElement element1 = doc.createElement("para");
element1.setAttribute("name", "center");
element1.setAttribute("x", para.center[]);
element1.setAttribute("y", para.center[]);
element1.setAttribute("z", para.center[]);
root.appendChild(element1); QDomElement element2 = doc.createElement("para");
element2.setAttribute("name", "normal");
element2.setAttribute("x", para.normal[]);
element2.setAttribute("y", para.normal[]);
element2.setAttribute("z", para.normal[]);
root.appendChild(element2); return doc.toString();
}
此方法在本地运行正常,但将其封装导出为一个DLL文件,再次调用时,一直报错:“Access violation writing location”。跟踪代码,发现出了这个函数,在return后就会报错,即使将这个doc.toString()拷贝出来,甚至使用QString的deep copy:
QString str(doc.toString().toLocal8Bit ());
return str;
仍报错这个错。Google了好久,也没发现原因。
JL之前说QDomElement递归调用时会各种出错,于是感觉是否QDomDocument这个方法不靠谱。。。
(1) 换用QxmlStreamWriter, 直接返回时,是bad prt,用QString 的deep copy后,可以得到正确的结果。但换用这个方法,工程中用到QDomDocument的地方都要改,改动太大,太麻烦。
(2) 继续搜,猛然发现一帖,说也在使用QDom时出现了violation的问题,结果是由于引用的lib不是Debug版的QtXmld4.lib。而是QtXml4.lib。 醍醐灌顶,一查我的工程,果然也是这个lib错写成Release版的了。改为QtXmld4.lib后,问题得解!!
这个错误太2了,以后吸取教训,出现violation错误时, 要记得看看是否是导入的lib库Debug 、Release搞混了。Mark~
QDomDocument Access violation writing location的更多相关文章
- 使用scanf_s报错:0xC0000005: Access violation writing location 0x00000000
在vs2010中写了一行scanf("%s",name); 调式时 提示warning , 提示修改为scanf()使用可能会存在不安全,建议使用scanf_s() 但是我修改成s ...
- VS2010程序崩溃,报错Unhandled exception at **.exe:0xC0000005: Access violation reading location 0x000000008899.
最近被派到另外一个组支援,从而从Linux下开发暂转到Windows下开发,个人觉得Windows自己搞的一套并不那么完美,坑多. 网文可能出现的原因: 未处理的异常: 0xC0000005: 读取位 ...
- std::vector push_back报错Access violation
C/C++ code ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include < ...
- STM32 KEIL不能输入仿真引脚端口error 65: access violation at 0x40021000 : no 'read' permission
使用MDK自己创建一个STM32F103ZE核的项目 加入源码后编译,正常,在线仿真单步执行出现如下问题 error 65: access violation at 0x40021000 : no ' ...
- 如何捕获access violation异常
文章目录 access violation的由来 access violation的实例 Win32 exception SEH异常与C++标准异常 捕获方法 1.access violation的由 ...
- 动态调用DLL函数有时正常,有时报Access violation的异常
动态调用DLL函数有时正常,有时报Access violation的异常 typedef int (add *)(int a,int b); void test() { hInst=LoadL ...
- Access Violation at address 00000000.Read of address 00000000 解决办法
是数组越标或没有初始化某个对象之类的问题,搂住细细检查一下代码, 使用指针前未做检查,而这个指针未初始化. 可能是new后没有delete,这样出现溢出的可能性比较大 检查代码或者跟踪试试 使 ...
- u-boot TFTP: 'Access violation' (2)
今天做tftp下载时间会遇到以下问题. --->8--- Load address: 0x20000000 Loading: * TFTP error: 'Access violation' ( ...
- laravel migrate时报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
今天在学习laravel的路由模型绑定时,在按照文档执行php artisan migrate时报错. In Connection.php line 664: SQLSTATE[42000]: Syn ...
随机推荐
- PL/SQL 批量SQL
批量SQL包括: FORALL语句 BULK COLLECT子句 FORALL语句 FORALL具有如下结构: FORALL loop_counter IN bounds_clause [SAVE E ...
- 控件AutoCompleteTextView实现动态匹配输入内容的一种输入框
<AutoCompleteTextView android:layout_width="match_parent" android:layout_height="w ...
- Gprinter Android SDK V2.1.4 使用说明
佳博打印机Android的SDK开发包,已更新到Gprinter Android SDK V2.1.4. IOS的SDK开发包更新为GprinterSDKandDemoforIOS_v1.0.8. 根 ...
- 获取IP所在地
$source=file_get_contents('http://www.ip138.com/ips138.asp?ip='.$ip.'&action=2'); preg_match_all ...
- 在xcode6.1和ios10.10.1环境下实现app发布
之前写过在xcode6.1和ios10.10.1环境下实现真机测试,以及最近提交的app一直在审核当中,所以木有发布如何实现app发布来分享给大家.刚好昨天app审核通过了,所以就分享一篇如何实现ap ...
- cocos2d-x编译错误问题
在xcode中创建的cocos2d-x项目,然后添加了一个基类,里面有虚方法,编译时出错,错误如下: Undefined symbols for architecture x86_64: " ...
- windowsphone 中CollectionViewSource和ObservableCollection的使用
功能描述:一级菜单省份 联动显示省份下的城市 直接上代码 public class City { public string Num { get; set; } public string Name ...
- html良好结构-之豆瓣风格
良好HTML结构 1 结构层次 unit> hd+ unit-wrap>section>item2 语议化的结构 html5 html 语议 ck-box-unit ck-hd-wr ...
- python之json
import json import requests re = requests.get('http://wthrcdn.etouch.cn/weather_mini?city=成都') re.en ...
- Vim及VimScript资料总结《转载》
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] Vim教程 入门 Vim 实用技术 Learning the vi and Vim Editors A Byte of ...