10 Replies - 3220 Views - Last Post: 05 January 2013 - 11:52 AM Rate Topic: -----

#1 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,002
  • Joined: 30-July 08

SFML 2.0 Text problem, program crashes.

Posted 18 December 2012 - 11:39 AM

When I compile and run my application it crashes with the following message:
Unhandled exception at 0x0F7F665A (sfml-graphics-d-2.dll) in codeCounter.exe: 0xC0000005: Access violation reading location 0x41700058.

I do not know why!

The class the problem is inside
#ifndef DRAW_H
#define DRAW_H
#include <SFML\Graphics.hpp>

class Draw
{
public:
	Draw();
	~Draw();

	void setWindow(sf::RenderWindow* rw);
	void drawBox();
	void drawText(int x, int y, std::string text);
	void drawLine();

private:
	sf::RenderWindow* m_Window;
	sf::RectangleShape m_Box;
	sf::Font m_Font;
	sf::Text m_Text;
};

#endif


Here is the function that the problem is in (I think):
void Draw::drawText(int x, int y, std::string text)
{
	m_Text.setString(text); // Visual Studio complain on this line
	m_Text.setFont(m_Font);
	m_Text.setCharacterSize(12);
	m_Text.setStyle(sf::Text::Regular);
	m_Text.setColor(sf::Color::Black);
	m_Text.setPosition(x, y);

	m_Window->draw(m_Text);
}


In the "Autos" tab I can see my m_Text variable and it say "<Information not available, no symbols loaded for sfml-graphics-d-2.dll>" and under the "sf::Drawable -> __vfptr" it say "0x00000000 { ???, ??? } -> [ 0 ] <unable to read memory>, [ 1 ] <unable to read memory>"

Anyone that has any clue what could be wrong and what I can try to fix it.

Is This A Good Question/Topic? 0
  • +

Replies To: SFML 2.0 Text problem, program crashes.

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: SFML 2.0 Text problem, program crashes.

Posted 18 December 2012 - 11:57 AM

What development environment are you using? You will need to be able to debug your code if no one knows what could be the problem off hand.
Was This Post Helpful? 0
  • +
  • -

#3 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,002
  • Joined: 30-July 08

Re: SFML 2.0 Text problem, program crashes.

Posted 19 December 2012 - 05:45 AM

I am using VS 2012. I have no clue how to find what is wrong with that problem.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: SFML 2.0 Text problem, program crashes.

Posted 19 December 2012 - 07:48 AM

Hit 'F5' and let the code run. When it crashes tell us precisely what the message is.
Was This Post Helpful? 0
  • +
  • -

#5 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,002
  • Joined: 30-July 08

Re: SFML 2.0 Text problem, program crashes.

Posted 20 December 2012 - 08:15 AM

It is the message I posted in the head of the topic:
"Unhandled exception at 0x0F7F665A (sfml-graphics-d-2.dll) in codeCounter.exe: 0xC0000005: Access violation reading location 0x41700058."
There is no other messages.
Was This Post Helpful? 0
  • +
  • -

#6 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,002
  • Joined: 30-July 08

Re: SFML 2.0 Text problem, program crashes.

Posted 20 December 2012 - 08:18 AM

The precise message is the one I showed in the head of the topic
"Unhandled exception at 0x0F7F665A (sfml-graphics-d-2.dll) in codeCounter.exe: 0xC0000005: Access violation reading location 0x41700058." there is no other message.
Was This Post Helpful? 0
  • +
  • -

#7 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: SFML 2.0 Text problem, program crashes.

Posted 20 December 2012 - 10:32 PM

What about the call stack? You should be able to tell from the list the last few functions executed.

It is clear that an allocation is failing somewhere because you are referencing a null pointer.
Was This Post Helpful? 0
  • +
  • -

#8 BlueMelon  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 187
  • Joined: 27-April 10

Re: SFML 2.0 Text problem, program crashes.

Posted 21 December 2012 - 09:33 PM

"sfml-graphics-d-2.dll" implies the debug mode.

You are dynamically linking them under debug configuration?
Was This Post Helpful? 0
  • +
  • -

#9 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,002
  • Joined: 30-July 08

Re: SFML 2.0 Text problem, program crashes.

Posted 22 December 2012 - 07:54 AM

View PostBlueMelon, on 22 December 2012 - 05:33 AM, said:

"sfml-graphics-d-2.dll" implies the debug mode.

You are dynamically linking them under debug configuration?

I use the standard settings I just told the IDE where to find the files. If I shouldn't dynamically link them, how do I change it and where? I place the DLLs in the debug map afterwards.
Was This Post Helpful? 0
  • +
  • -

#10 BlueMelon  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 187
  • Joined: 27-April 10

Re: SFML 2.0 Text problem, program crashes.

Posted 22 December 2012 - 08:08 AM

I follow the settings posted here

Mind you, it might not be a problem with your settings.
It could be a problem with your code, Access violation errors usually mean that you try to access memory which has been deleted or dereferenced. Looking at the callstack and stepping through your code will help you find where its coming from.

This post has been edited by BlueMelon: 22 December 2012 - 08:22 AM

Was This Post Helpful? 0
  • +
  • -

#11 odkken  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-January 13

Re: SFML 2.0 Text problem, program crashes.

Posted 05 January 2013 - 11:52 AM

I had a maybe similar issue that I resolved, here's the thread: http://en.sfml-dev.o...p?topic=10183.0

Basically make sure the memory for the object with the text is being allocated correctly.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1