1
General discussions / Re : SFML Game Development by Example - 4th SFML book
« on: October 15, 2016, 06:49:21 pm »
(You can find attached a pic from the debugger)
GUI_Event
EventInfo
and to me, it looks like it is crashing around here (from EventManager::loadBindings())
GUI_Event
struct GUI_Event {
GUI_EventType mType;
const char *mElement;
const char *mInterface;
union {
ClickCoordinates mClickCoords;
};
};
GUI_EventType mType;
const char *mElement;
const char *mInterface;
union {
ClickCoordinates mClickCoords;
};
};
EventInfo
struct EventInfo {
EventInfo() { mCode = 0; }
EventInfo(int event) { mCode = event; }
EventInfo(GUI_Event &guiEvent) { gui = guiEvent; }
union
{
int mCode;
GUI_Event gui;
};
};
EventInfo() { mCode = 0; }
EventInfo(int event) { mCode = event; }
EventInfo(GUI_Event &guiEvent) { gui = guiEvent; }
union
{
int mCode;
GUI_Event gui;
};
};
and to me, it looks like it is crashing around here (from EventManager::loadBindings())
if (type == EventType::GUI_Click || type == EventType::GUI_Hover ||
type == EventType::GUI_Release || type == EventType::GUI_Leave)
{
start = end + delimiter.length();
end = keyval.find(delimiter, start);
std::string window = keyval.substr(start, end - start);
std::string element;
if (end != std::string::npos) {
start = end + delimiter.length();
end = keyval.length();
element = keyval.substr(start, end);
}
char *w = new char[window.length() + 1]; // +1 for '\0'
char *e = new char[element.length() + 1];
strcpy_s(w, window.length() + 1, window.c_str());
strcpy_s(e, element.length() + 1, element.c_str());
eventInfo.gui.mInterface = w;
eventInfo.gui.mElement = e;
}
type == EventType::GUI_Release || type == EventType::GUI_Leave)
{
start = end + delimiter.length();
end = keyval.find(delimiter, start);
std::string window = keyval.substr(start, end - start);
std::string element;
if (end != std::string::npos) {
start = end + delimiter.length();
end = keyval.length();
element = keyval.substr(start, end);
}
char *w = new char[window.length() + 1]; // +1 for '\0'
char *e = new char[element.length() + 1];
strcpy_s(w, window.length() + 1, window.c_str());
strcpy_s(e, element.length() + 1, element.c_str());
eventInfo.gui.mInterface = w;
eventInfo.gui.mElement = e;
}