Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mudderhino |
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 get_drag_data() 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:
On runtime, the Inventory slots get added to InventoryDisplay which look like this:
Please let me know if you need any more information