Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Fix PCKPacker error spam #68735

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

dzil123
Copy link
Contributor

@dzil123 dzil123 commented Nov 16, 2022

After PCKPacker.flush(), the file is closed and it is invalid to call flush() or add_file(), but the closed file isn't properly detected because the FileAccess remains nonnull and add_file() doesn't check for a closed file, causing flush() to spam error messages and add_file() to miss the error. This PR fixes that.

With this script:

extends Node

func _ready():
        var packer = PCKPacker.new()
        packer.pck_start("res://out.pck")
        packer.flush()
        packer.flush()
        print()

        packer.add_file("", "icon.png")

Error messages before:

ERROR: File must be opened before use.
   at: store_8 (drivers/unix/file_access_unix.cpp:261)
ERROR: File must be opened before use.
   at: store_8 (drivers/unix/file_access_unix.cpp:261)
ERROR: File must be opened before use.
   at: store_8 (drivers/unix/file_access_unix.cpp:261)
ERROR: File must be opened before use.
   at: store_8 (drivers/unix/file_access_unix.cpp:261)
ERROR: File must be opened before use.
   at: get_position (drivers/unix/file_access_unix.cpp:205)
ERROR: File must be opened before use.
   at: get_position (drivers/unix/file_access_unix.cpp:205)

Error messages after:

ERROR: File must be opened before use.
   at: flush (core/io/pck_packer.cpp:111)

ERROR: File must be opened before use.
   at: add_file (core/io/pck_packer.cpp:89)

Compatible with 3.5.

@dzil123 dzil123 requested a review from a team as a code owner November 16, 2022 15:01
@akien-mga akien-mga added bug topic:core cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release labels Nov 16, 2022
@akien-mga akien-mga added this to the 3.6 milestone Nov 16, 2022
@akien-mga
Copy link
Member

Is this relevant for 4.0?

@dzil123
Copy link
Contributor Author

dzil123 commented Nov 17, 2022

The equivalent 4.0 PR is #67619.

@akien-mga akien-mga merged commit 08a6aab into godotengine:3.x Nov 18, 2022
@akien-mga
Copy link
Member

Thanks!

@timothyqiu
Copy link
Member

Cherry-picked for 3.5.2

@timothyqiu timothyqiu removed the cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release label Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants