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

Author Topic: [SOLVED] Not having a sf::text crashes my code  (Read 2381 times)

0 Members and 1 Guest are viewing this topic.

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
[SOLVED] Not having a sf::text crashes my code
« on: March 04, 2013, 08:44:12 pm »
I happened to encounter an unusual thing. I made a Breakout clone, and I wanted to make another game, using the same screens, and changing Texts, etc.
Before I had 3 sf::text and now I want only one. So I erased one(erase all the code concerning that sf::text), and everything works, but when I want to erase the other one it crashes as soon as it loads it. Also, it crashes only on Release mode, so I can't use watches, breakpoints, etc.

This is the error that gives me "Process terminated with status -1073741676", apparently it is a division by 0 error.

Strangely enough, I can remove everything but the .setString() line. Everything else I can remove it and it works, even the window.draw(_textoSetCentradoTitulo) line. (code below)

any ideas?

MenuSeleccion.h
class MenuSeleccion : public GameState{

    private:
    Text _textoPrimerosPasos;
    Text _textoSetCentradoTitulo;

 public:
    MenuSeleccion();

    void eventosYMuevo();
    void update();
    void render();

};

menuSeleccion.cpp
MenuSeleccion::MenuSeleccion(){

    _textoPrimerosPasos.setString("Primeros Pasos:");
    _textoPrimerosPasos.setCharacterSize (pantalla_alto * 7 / 120);
    _textoPrimerosPasos.setColor(myColor);
    _textoPrimerosPasos.setPosition(pantalla_alto * 2 / 15, pantalla_alto / 6);
    _textoPrimerosPasos.setFont(myFont);

    _textoSetCentradoTitulo.setString("Set Centrado:"); ///I can remove everything but this line
    //_textoSetCentradoTitulo.setCharacterSize (pantalla_alto * 7 / 120);
    //_textoSetCentradoTitulo.setColor(myColor);
    //_textoSetCentradoTitulo.setPosition(pantalla_alto * 2 / 15, pantalla_alto * 17 / 30);
   // _textoSetCentradoTitulo.setFont(myFont);

}
...
 
« Last Edit: March 05, 2013, 04:34:37 am by santiaboy »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Not having a sf::text crashes my code
« Reply #1 on: March 04, 2013, 09:49:58 pm »
We can't help you with the provided code.
You need to give us a complete and minimal example, which reproduces the problem. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Not having a sf::text crashes my code
« Reply #2 on: March 04, 2013, 11:08:57 pm »
Thanks for the answer, but I think my code has other issues.
I've been tinkering around since I posted this, and found other problems, which may have caused the error, and somehow it was related to the Text, because now I can remove it.

I guess i'ts solved..?

Haikarainen

  • Guest
Re: Not having a sf::text crashes my code
« Reply #3 on: March 04, 2013, 11:18:05 pm »
For your information (and anyone else stumbling upon this while searching or something); My guess is that you just copy pasted the projectfiles and included the obj-folder, and didnt rebuild everything.. Strange stuff can happen when you do these kinds of things, especially if you leave out certain files when copying the project.. Can also be IDE related.

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Not having a sf::text crashes my code
« Reply #4 on: March 05, 2013, 04:34:19 am »
I did rebuild, and nothing changed. What I did was I made a template(code::blocks has this integrated), and started working from there.

I had other issues that had nothing to do with sf::Text, but strangely enough, if I erased that line of code, everything went to hell.

In any case, I solved it, yay. 8)

 

anything