So I have the cl_Page class:
class cl_Page{
public:
cl_Page(cl_LessonMoment *parent_param);
cl_Page(cl_SoftRoot *parent_param);
int parent_type;
cl_LessonMoment *parent_lmoment;
cl_SoftRoot *parent_softroot;
char id[256];
//<content>
//Backgrounds.
str_Color bgcolor;
cl_Image bgimage;
//Actual content
vector<cl_Textbox> textboxes;
vector<cl_Button> buttons;
vector<cl_Image> images;
//</content>
cl_Textbox* AddTextbox();
cl_Button* AddButton();
cl_Image* AddImage(char *filename = nullptr);
};
and the cl_Page constructors:
cl_Page::cl_Page(cl_LessonMoment *parent_param) : bgimage(nullptr){ //here is the segfault
parent_lmoment = parent_param;
parent_type = 1;
id[0] = '\0';
SetColor(bgcolor, 0xffffffff);
}
cl_Page::cl_Page(cl_SoftRoot *parent_param): bgimage(nullptr){ // or here if i call this constructor
/*parent_softroot = parent_param;
parent_type = 2;
id[0] = '\0';
SetColor(bgcolor, 0xffffffff);*/
}
What happens is that, no matter how I call the constructors, or no matter which one I call (the second is all commented out; so basically empty), global, local or dynamically, in a function or as a member object, I get a segmentation fault which appears to be right on the cl_Page::cl_Page(cl_LessonMoment *parent_param) : bgimage(nullptr){ line. The call stack looks like this:
#0 77C460CB strcat() (C:\WINDOWS\system32\msvcrt.dll:??)
#1 0022F168 ?? () (??:??)
#2 00401905 cl_Page::cl_Page(this=0x22fbe8, parent_param=0x0) (F:\Scoala\C++\EduSoftViewer_Parser\sources\classes\soft_tree\page.cpp:10)
#3 00402B8A main() (F:\Scoala\C++\EduSoftViewer_Parser\sources\main.cpp:11)
On some builds before I am writing this, (with exactly the same issue) the #1 position on the call stack, where now is ?? () (??:??) was ntdll!RtlDosApplyFileIsolationRedirection_Ustr() (C:\WINDOWS\system32\ntdll.dll:??).
So my question is: Does anybody know what is causing this? I really need to get this working.
If anything is unclear, just ask and I'll provide additional information.
EDIT: To clarify: I'm under Windows XP SP2 and running Code::Blocks with gcc.
EDIT 2: The cl_Image constructor:
cl_Image::cl_Image(char *filename_param){
if (filename == nullptr){
filename[0] = '\0';
}
else{
strcpy(filename, filename_param);
}
SetPosition(position, 0, 0);
id[0] = '\0';
visible = 1;
z_index = 0;
}
This class doesn't contain any object members, with the exception of a POD struct, position
EDIT 3: The cl_Image class:
class cl_Image{
public:
cl_Image(char* filename_param = nullptr);
str_Position position;
char filename[256];
char id[256];
bool visible;
int z_index;
};
str_Position is just a struct of 2 ints.
filenamemember,idmember, etc ofcl_Imagelooks like? (for that matter, the entire class def would probably be handy)