call stack:
> sfml-graphics-d-2.dll!std::_Tree<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Lbound(const unsigned int & _Keyval) Line 2109 C++
sfml-graphics-d-2.dll!std::_Tree<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::lower_bound(const unsigned int & _Keyval) Line 1575 C++
sfml-graphics-d-2.dll!std::map<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> > >::operator[](const unsigned int & _Keyval) Line 226 C++
sfml-graphics-d-2.dll!sf::Font::getGlyph(unsigned int codePoint, unsigned int characterSize, bool bold) Line 295 C++
sfml-graphics-d-2.dll!sf::Text::ensureGeometryUpdate() Line 269 C++
sfml-graphics-d-2.dll!sf::Text::getLocalBounds() Line 214 C++
Engine.exe!Text::getLocalBounds() Line 41 C++
Engine.exe!Button::setTextSize(unsigned int textSize) Line 56 C++
Engine.exe!Button::setString(std::basic_string<char,std::char_traits<char>,std::allocator<char> > text) Line 47 C++
Engine.exe!Button::Button(std::basic_string<char,std::char_traits<char>,std::allocator<char> > text, unsigned int textSize, sf::Vector2<float> pos, sf::Color textColor, sf::Color buttonFaceColor) Line 7 C++
Engine.exe!Missile_Command::initButtons() Line 56 C++
Engine.exe!Missile_Command::init() Line 29 C++
Engine.exe!Missile_Command::Missile_Command() Line 6 C++
Engine.exe!main() Line 4 C++
[External Code]
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
code:
void Text::draw(sf::RenderTarget & target, sf::RenderStates states) const{
target.draw(text);
}
which was called by:
void Button::draw(sf::RenderTarget & target, sf::RenderStates states) const{
target.draw(buttonFace);
target.draw(text);
}
No pointers were used to my knowledge.
The exact error is as follows:
Unhandled exception at 0x0F21F95C (sfml-graphics-d-2.dll) in Engine.exe: 0xC0000005: Access violation reading location 0x0000000D.
I've been trying to solve this for quite some time now. I think it has something to do with my sf::Text object not being properly initialized or something, but I couldn't find anything.
Here's the my Text class if anyone's interested:
#include "init.h"
Text::Text(sf::Vector2f pos, size_t size, sf::Color color, std::string text, std::string font){
setPosition(pos);
setSize(size);
setColor(color);
setText(text);
setFont(font);
}
Text::Text(std::string font, std::string text){
setText(text);
setFont(font);
}
std::string Text::getString() const{
return text.getString();
}
sf::Text Text::getText() const{
return text;
}
sf::Color Text::getColor() const{
return text.getColor();
}
int Text::getSize() const{
return text.getCharacterSize();
}
sf::Vector2f Text::getPosition() const{
return text.getPosition();
}
sf::Font Text::getFont() const{
return font;
}
sf::FloatRect Text::getLocalBounds() const{
return text.getLocalBounds();
}
void Text::setText(std::string text){
if (text != "" && text != " ")
this->text.setString(text);
}
void Text::setColor(sf::Color color){
text.setColor(color);
}
void Text::setSize(size_t size){
text.setCharacterSize(size);
}
void Text::setPosition(sf::Vector2f pos){
text.setPosition(pos);
}
void Text::setFont(std::string file){
if (!font.loadFromFile(file)){
std::exit(-1);
}
text.setFont(font);
}
void Text::draw(sf::RenderTarget & target, sf::RenderStates states) const{
target.draw(text);
}
"text" and "font" are private class members.