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

Author Topic: loadFromFile fails without error message, still loads the texture.  (Read 1839 times)

0 Members and 1 Guest are viewing this topic.

asim-v

  • Newbie
  • *
  • Posts: 2
    • View Profile
Having a weird behavior here with SFML 2.5.1

   
    if (!m_sftexture->loadFromFile(m_filepath));
    {
        std::cout << "--Warn-- Unable to load texture from : " << m_filepath << std::endl;
    }
    m_sfsprite->setTexture(*m_sftexture, true);
 

I can post more information if necessary, but the sprite is still drawn to the screen. The only output I get is my own warning message meaning loadFromFile returned false. If I butcher the file path then I get the error message stating it is unable to find the file.

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: loadFromFile fails without error message, still loads the texture.
« Reply #1 on: November 27, 2019, 10:35:28 pm »
You have a ; at the end of the if. So the if doesn't matter and what is in the brackets will always be executed.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

asim-v

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: loadFromFile fails without error message, still loads the texture.
« Reply #2 on: November 28, 2019, 01:58:46 am »
Holy shit I was so confused by this... thanks.