Exported binary hanging

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nosrick
:warning: 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:

		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)

var temp = directory.get_next()
while temp != "":
	if(temp == "." or temp == ".."):
		temp = directory.get_next()
		print("Got directory, ", temp)
		Load(baseDirectory + "/" + temp)
		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

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

:bust_in_silhouette: Reply From: volzhs

I don’t know what’s wrong with Dicrectory.get_current_dir().
But ResourceLoader.load(baseDirectory + "/" + temp) will work instead of using directory.get_current_dir()

:bust_in_silhouette: Reply From: nosrick

So I found out what it is:
Don’t use directory.get_current_dir().
I don’t know why.