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

GDScript: Prevent constructing and inheriting engine singletons #82098

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Sep 22, 2023

You cannot create a new instance of an engine singleton.

godot/core/os/time.cpp

Lines 446 to 449 in fe5b1c8

Time::Time() {
ERR_FAIL_COND_MSG(singleton, "Singleton for Time already exists.");
singleton = this;
}

@dalexeev dalexeev added this to the 4.2 milestone Sep 22, 2023
@dalexeev dalexeev requested a review from a team as a code owner September 22, 2023 07:14
@dalexeev dalexeev force-pushed the gds-prevent-engine-singleton-inheritance branch from 38e9a5b to 285ddc8 Compare September 22, 2023 07:46
@dalexeev dalexeev changed the title GDScript: Prevent engine singleton inheritance GDScript: Prevent constructing or inheriting engine singletons Sep 22, 2023
@dalexeev dalexeev changed the title GDScript: Prevent constructing or inheriting engine singletons GDScript: Prevent constructing and inheriting engine singletons Sep 22, 2023
@dalexeev dalexeev force-pushed the gds-prevent-engine-singleton-inheritance branch 2 times, most recently from 3e39594 to 385791a Compare September 22, 2023 11:21
Copy link
Contributor

@ryanabx ryanabx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks Dalexeev as always!

modules/gdscript/gdscript_analyzer.cpp Outdated Show resolved Hide resolved
modules/gdscript/gdscript_analyzer.cpp Outdated Show resolved Hide resolved
@dalexeev dalexeev force-pushed the gds-prevent-engine-singleton-inheritance branch from 385791a to 10b00bc Compare September 22, 2023 14:30
@akien-mga akien-mga merged commit 1c10ff3 into godotengine:master Sep 22, 2023
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants