0 votes

Hello everyone, I have tried to solve this problem multiple times but just can't wrap my head around it.
I basically have a Tab container with both an Inventory and Crafting tab. The Inventory tab is what causes the problem here. Every time I pick up an Item, a drag preview gets set as shown in my code:

func get_drag_data(_position):
    var itemIndex = get_index()
    var item = inventory.items[itemIndex]
    var dragPreview
    var data = {}
    if item != null:
        # Notify specific Objects that an Item has been picked up
        # so they stop working
        if Inventories.getFurnaceInventoryByID(inventory.id) != null:
            Inventories.notifyMoving(true)
        dragPreview = TextureRect.new()
        dragPreview.texture = item.texture
        dragPreview.set_scale(Vector2(5, 5))
        print(dragPreview)
        data.id = inventory.id
        data.name = item.name
        data.previousAmount = item.amount
        # Set unhandled data in case the Item doesn't get dropped anywhere
        Inventories.setUnhandledData(inventory, item, item.amount, itemIndex)
        # For half-splitting Item Stacks
        if Input.is_action_pressed("ctrl"):
            if item is Item:
                item.amount /= 2
                data.item = item.duplicate()
                inventory.emit_signal("items_changed", inventory.id, itemIndex)
                data.itemIndex = itemIndex
                data.split = true
                set_drag_preview(dragPreview)
                print(inventory)
                return data
        # For moving Items
        else:
            item = inventory.remove(itemIndex)
            if item is Item:
                data.item = item
                data.itemIndex = itemIndex
                set_drag_preview(dragPreview)
                return data

From what I understand, the drag preview should be freed automatically when the data is returned in getdragdata() and all signals should get disconnected. As soon as I drop the Item, I get this error. [TextureRect:11843] being my drag preview and [TabContainer:1444] being the Tab container:

E 0:00:07.955   _disconnect: Attempt to disconnect a nonexistent connection to signal 'renamed' in [TextureRect:11843], with target '_child_renamed_callback' in [TabContainer:1444].   <C++ Error>   Condition "signal_is_valid" is true.   <C++ Source>  core/object.cpp:1569 @ _disconnect()

My tree looks like this:
https://imgur.com/a/m1GCjaN

On runtime, the Inventory slots get added to InventoryDisplay which look like this:
https://imgur.com/a/o513Ggv

Please let me know if you need any more information

Godot version 3.3.2 (Stable)
in Engine by (12 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.