Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Issues with Text objects in classes  (Read 1923 times)

0 Members and 1 Guest are viewing this topic.

Nyrox

  • Newbie
  • *
  • Posts: 9
    • View Profile
Issues with Text objects in classes
« on: November 19, 2014, 11:24:04 pm »
Hello(?)

I am having a problem with sf::Text object in classes, I was able to break the problem down to this: http://hastebin.com/ofeyozesay.avrasm

Just the pure fact that I make a call to .setString makes the program crash at TestClass::draw, because of access violation.
Callstack comes down to win.draw(testShape) in TestClass.

OS: Win7
I am using SFML 2.1 with dynamic linking

Thanks for helping.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Issues with Text objects in classes
« Reply #1 on: November 20, 2014, 01:47:26 am »
Hi  :)

The code that you posted compiles and runs fine for me (I had to change the backslash to a slash in the include but that's trivial).

Then, I uncommented everything: still fine.
Added testFont.loadFromFile and set it for testText and it displays it in the window.

There have been a number of fixes/modifications with the text parts of SFML since v2.1 so it would be wise to build the latest master for yourself (from here). Failing that, you could download a nightly build (from here).

On a side note, I'm curious as to why you used exit(0) instead of just window.close() as shown in the tutorials.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Nyrox

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Issues with Text objects in classes
« Reply #2 on: November 20, 2014, 02:26:23 am »
Okay thank you alot for doing that :D
I am going to rebuild sfml now and look if that changes anything. About the exit(0) thing, I just started doing that at some point, dunno why.:P

Edit:: And in the actual project where I had the error I do actually .close the window at cleanup, no worrys :D

Nyrox

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Issues with Text objects in classes
« Reply #3 on: November 20, 2014, 02:38:37 am »
Okay I updated to the most recent nightly build (I was to lazy to build from source) and now everything works nicely. Thank you alot. Still wondering what was causing the problem, I am pretty sure that I built correctly.
Well, but the fact that it works is good enough.

Thanks :D

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Issues with Text objects in classes
« Reply #4 on: November 20, 2014, 07:45:09 pm »
You're welcome. Glad you got it sorted  :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything