分段错误 .AnsiStringToUnicodeString 作为第一个调试错误行.杜比奥斯类等级制度
segmentation-fault .. AnsiStringToUnicodeString as first debug-error-line .. doobious class-hieracy
我试图让这些类保持 RAII 标准(正如我所得到的那样......我是一个业余程序员(,但编译器/调试器抱怨缺少构造函数(带空括号(,所以我添加了它们 + set_value(( 函数。
在一个简单的矩形上详细说明这么多的目的是从我试图处理的前景问题中消除集成GUI类型(自上而下的类型,如按钮和文本字段(的云性:openGL 2D和3d图形生活在左下角的坐标词干中。
enum class eAnker:int{
high_left,
high_right,
low_left,
low_right,
}
class anker
{
friend node_handler;
public:
anker(){};
anker(glm::dvec2 Vec2):pPoint( new glm::dvec2(Vec2) ){};
anker(glm::dvec2 Vec2, eAnker ea):pPoint( new glm::dvec2(Vec2) ),anker_type(ea){};
virtual ~anker(){ delete pPoint; };
void set_value(glm::dvec2){pPoint=new glm::dvec2(v);}
void set_anchor_type( eAnker ea){ anker_type=ea; }
bool operator<( anker& a ){ return (pPoint->x<a.pPoint->x)<(pPoint->y<a.pPoint->y); };
protected:
glm::dvec2* pPoint;
eAnker anker_type;
};
class nRect:public anker
{
friend node_handler;
public:
nRect(){};
nRect(glm::dvec2 p):anker(p){};
nRect(glm::dvec2 p,double lineHeight, double letterWidth):anker(p),plHeight( new double(lineHeight)), plWidth( new double(letterWidth) ){};
virtual ~nRect(){
delete plHeight;
delete plWidth;
};
void set_dims( double Ww, double Lh ){
plWidth= new double(Ww*LETTER_PIXEL_WIDTH);
plHeight=new double(Lh*LINE_PIXEL_HEIGHT);
}
protected:
double* plHeight;
double* plWidth;
};
class node:public nRect
{
friend node_handler;
public:
node(){};
node(glm::dvec2 p):nRect(p){};
node(glm::dvec2 p, double wW, double lH):nRect(p,wW,lH){};
virtual ~node(){};
void mouse_up(){
on_click();
};
virtual void on_click(){
/*
bool b = !set_bit::is_closed(myBits);
set_bit::as_closed(myBits,b);
*/
};
protected:
vector<node>::iterator iParent;
bitset<32> myBits;
string string_data;
double my_ratio;
glm::dvec2 cursor_old;
};
class node_handler
{
public:
node_handler(){}
~node_handler(){};
void set_root( glm::dvec2 anker, double pixel_width, double pixel_height ){
if(!root_lock){
node n(anker,pixel_width/25.0d,pixel_height/12.0d) ;
n.string_data="root";
n.iParent = nodes.end();
nodes.resize(10);
nodes.at(0) = n ;
current=nodes.begin();
root_lock=true;
node_counter++;
}
else{
//cout << "BEEP nodes.root-errorn" << char(7);
}
}
void split_current( double ratio, bool as_horizontal ){
pair<node,node> res = split(current,ratio,as_horizontal);
res.first.string_data="-closer";
res.first.iParent=current;
res.second.string_data="-farther";
res.second.iParent=current;
if(node_counter<int(nodes.size()) ) {
nodes.at(node_counter)=res.first;
current=nodes.begin()+node_counter;
node_counter++;
nodes.at(node_counter)=res.second;
node_counter++;
}
else{
cout << "no handler-space for more nodesn" ;
}
//no errors so far. when leaving split_current(..), the execution halts with a SIGSEGV
}
protected:
int node_counter=0;
private:
pair<node,node>split( vector<node>::iterator& this_node, double ratio, bool as_horizontal ){
this_node->my_ratio=ratio;
double firstW, firstH;
double secW, secH;
glm::dvec2 afirst, asecond;
if(as_horizontal ){
// set values
}
return make_pair<node,node>( node(afirst ,firstW, firstH), node(asecond ,secW, secH) ) ;
}
vector<node>::iterator current;
vector<node> nodes;
bool root_lock{false};
};
/////////////////////
主测试:
node_handler nh;
glm::dvec2 minor=glm::dvec2(0.0d, 0.0d);
double width=800.0d;
double height=600.0d;
nh.set_root(minor,width,height);
nh.split_current( 1.0d/10.0d , true );
//see nh.split_current() where SIGSEGV happens
The debug error-trace leaves 10 lines, noone pointing to a specific line in my code:
ntdll!RtlAnsiSringToUnicodeString()
??()
std::basic_Ostream<.....
std::clog()
std::clog()
??()
msvcat!_iob()
vtable for ct::anker
std::piecewise_construct
链接是同一代码的后续链接,可能包含所描述的不稳定行为的正确答案。简而言之(据我了解(:带有指针成员的类需要自定义的复制/赋值运算符,这些它们在您编写的代码后面工作,无需您通知......默认的将不起作用。 我没有提供它们。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- C++中"覆盖功能的异常规范比基本版本更宽松"的奇怪错误
- 分段错误 .AnsiStringToUnicodeString 作为第一个调试错误行.杜比奥斯类等级制度
- 当 2 个线程共享同一物理内核时,具有错误共享的易失性增量在发布中的运行速度比在调试中慢
- 我的 C++11 测试表明 sort(vector<string>) 甚至比 C++03 慢,有什么错误吗?
- 在编译发布时使用什么工具来查找c++错误.助推::阿西奥,cmake.vs2012.十字路口/0mq
- C++用于解码MKV视频(杜比数字/ AVC)的库
- 在Visual Studio中编码错误比涡轮增压C++ - C
- 使用static_assert()提供更好的编译时错误(比编译器)
- 奥威尔开发C++致命错误:"iostream: no such file or directory"
- 为什么调试器在发生错误时比编译器更具体
- 阿杜伊诺崇高文本 2.我可以编译但不能上传。错误"The system cannot find the file specified"