Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nosrick | |
Old Version | Published before Godot 3 was released. |
As the topic suggests, my exported binary is hanging. This occurs when I try to load textures. My texture loader recursively searches through the directories in the folder I point it at, and that’s where it’s falling down; on the recursion.
Here’s a code snippet:
if(directory.current_is_dir()):
print("Got directory, ", temp)
Load(baseDirectory + "/" + temp)
This is in the Load function, so it is calling itself to go down a directory. This works perfectly in the IDE, but when exported, causes the application to hang permanently, without any indication that it’s called Load().
Does Godot have a problem, or do I?
reference document says:
bool current_is_dir() const
Return whether the current item processed with the last get_next() call is a directory (. and … are considered directories).
did you also check directory
is not .
nor ..
?
volzhs | 2016-06-22 17:12
Yeah, I did.
Here’s the full code:
func Load(path = "res://Content/Sprites/Uncut/"):
var directory = Directory.new()
var baseDirectory = path
print("Got path ", baseDirectory)
directory.change_dir(baseDirectory)
directory.list_dir_begin()
var temp = directory.get_next()
while temp != "":
if(temp == "." or temp == ".."):
temp = directory.get_next()
continue
if(directory.current_is_dir()):
print("Got directory, ", temp)
Load(baseDirectory + "/" + temp)
else:
print("Got file, ", temp)
var extension = temp.substr(temp.find_last("."), 4)
if(extension == ".png"):
var name = temp.substr(0, temp.length() - 4)
textures[name] = ResourceLoader.load(directory.get_current_dir() + "/" + temp)
print("Loaded ", name)
temp = directory.get_next()
nosrick | 2016-06-22 17:21
Addendum:
This still happens if I take the recursion out.
It will load the first file it finds, then hang forever.
nosrick | 2016-06-22 19:28
It actually looks like ResourceLoader.load() is the problem. That’s where it stops outside of the debug environment.
nosrick | 2016-06-22 19:38