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

Author Topic: loadFromFile() randomly fails  (Read 1174 times)

0 Members and 1 Guest are viewing this topic.

mperic

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
loadFromFile() randomly fails
« on: March 30, 2022, 06:24:10 pm »
Hi.

I am using SFML for the graphics of an ant simulation, and I am loading textures and fonts using loadFromFile(). All of these loadFromFile() calls are happening under one iteration of a loop, and when the simulation ends, the loop restarts, and loadFromFile() is called again. This works fine, but after about 3-5 hours of the loop restarting (one iteration of the loop takes appoximately 30 minutes) some of my textures won't load. And then usually, the next iteration will have no textures load.

Any idea why this may be happening?

I suspect that there may be some kind of problems occurring with file buffers since I am not closing the streams at the end of each iteration/

Is there any way to close the loadFromFile() file streams manually? Is there another possible problem here?

Thanks,
mperic

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: loadFromFile() randomly fails
« Reply #1 on: March 30, 2022, 07:11:29 pm »
Why would you be reloading textures and fonts hours on end?

Since you mention streams, are you calling loadFromFile or loadFromStream?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mperic

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: loadFromFile() randomly fails
« Reply #2 on: March 30, 2022, 09:01:59 pm »
I am calling loadFromFile().

Why would you be reloading textures and fonts hours on end?

This was forked from another repository, and I don't think it was ever intended to be restarted like this. Now that you mention it, I do have a centralized text-manager struct that I could use, as it only loads fonts and textures once. However, I do have map loading which would be reloaded repeatedly. I would have to find a way to pre-load the maps accordingly.

I suppose it would be advisable to load everything once rather than reloading it repeatedly.  ;) Thanks for your response.
« Last Edit: March 30, 2022, 09:10:04 pm by mperic »

 

anything