Class inheritance method override does not work in 4.8 beta 1

Đã đóng
#2,083 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp, godot
Lĩnh vực
backend

Hướng nghiên cứu

Start with the reproduction in addons/test/cTest.h and main.gd, then compile it with addons/test/compite_debug.sh using Godot 4.8 beta and the listed godot-cpp commits. Compare the inherited test method behavior with versions before 4.8; done when b.test(im) accepts the Image argument while a.test(ba) still works.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Godot version

4.8.beta1

godot-cpp version

1b089f20a959e67e79e32e352a57065b3058dbfd

System information

Ubuntu 24.04

Issue description

We have two classes, see reproduction project (addons/test/cTest.h):

class cTestA : public RefCounted {
	GDCLASS(cTestA, RefCounted)

    public: 
        cTestA(){}
        ~cTestA(){}
        void test(PackedByteArray byte_array){
            UtilityFunctions::print("cTestA: test function call: PackedByteArray");
        }
    protected:
        static void _bind_methods(){
            ClassDB::bind_method(D_METHOD("test", "byte_array"), &cTestA::test);
        };
};

class cTestB : public cTestA {
	GDCLASS(cTestB, cTestA)
   
    public:
        cTestB(){}
        ~cTestB(){}
        void test(Ref<Image> image){
            UtilityFunctions::print("cTestB: test function call: Ref<Image>");
        }
    protected:
        static void _bind_methods(){
            ClassDB::bind_method(D_METHOD("test", "image2d"), &cTestB::test);
        };
};

But in GDScript (main.gd):

func _ready() -> void:
	var a := cTestA.new()
	var b := cTestB.new()
	var ba := PackedByteArray([0,0,0])
	var im := Image.create_empty(128, 128, false, Image.FORMAT_RF)
	a.test(ba)
	b.test(im)

I get an error: "Error at (8, 12): Invalid argument for "test()" function: argument 1 should be "PackedByteArray" but is "Image"."
This problem did not exist in any version <4.8.
Tested with:

  1. godot-cpp commit 1b089f20a959e67e79e32e352a57065b3058dbfd
  2. godot-cpp commit 507ed9d840c01a3c5b2a39af8bb4000bfac30bf5
Steps to reproduce

See reproduction project. Compile script: addons/test/compite_debug.sh
To compile:

cd addons/test
git clone [email protected]:godotengine/godot-cpp.git
chmod +x compite_debug.sh
./compite_debug.sh

then open this project in Godot 4.8 beta.

Minimal reproduction project

InheritanceTest.zip

Ngôn ngữ chính
C++
Star
2.8k
Fork
825
Merge trung bình
3 ngày 23 giờ
Pull request đã merge (30 ngày)
19

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của godotengine/godot-cpp

Tất cả issue của godotengine/godot-cpp

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.