This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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?

in Engine by (38 points)

reference document says:

bool currentisdir() 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 ..?

Yeah, I did.
Here's the full code:

func Load(path = "res://Content/Sprites/Uncut/"):
var directory =
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()

This still happens if I take the recursion out.
It will load the first file it finds, then hang forever.

It actually looks like ResourceLoader.load() is the problem. That's where it stops outside of the debug environment.

2 Answers

+1 vote
Best answer

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()

by (9,800 points)
selected by

reported this issue on github.

0 votes

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

by (38 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.