[BUG] ItemBox::endDrop() crashes BUG FOUND NEED FIX

sglorz

07-03-2011 22:56:37

Hello,

I have a strange behavior when calling void ItemBox::endDrop(bool _reset) an exception is raised because my ItemBox widget and its childs seems to have disappeared...

I've looked into the function and when I comment this line


mReseiverContainer = nullptr;


It doesn't crash anymore, but, of course, drag and drop is not working ;)

sglorz

08-03-2011 14:38:10

Sorry, ItemBox not DDContainer.

sglorz

08-03-2011 20:36:58

I've found the bug.

Here is the scenario:
1/ I receive a ItemBox drag event and returned result is true
2/ I receive a drop event and returned result is true
3/ But before eventRequestDrop(this, mDropInfo, mDropResult) returned, a call to reset_drag() is made.

When you look at the code


void DDContainer::mouseDrag(MouseButton _id)
{

[...]

if (item)
{
// делаем запрос на индекс по произвольному виджету
receiver = item->_getContainer();
// работаем только с контейнерами
if (receiver && receiver->isType<DDContainer>())
{
[...]

eventRequestDrop(this, mDropInfo, mDropResult); <--------------- Drop event sent, endDrop() called before event returned

// устанавливаем новую подсветку
mReseiverContainer->_setContainerItemInfo(mDropInfo.receiver_index, true, mDropResult); <------------------------- then mReseiverContainer is null
}

[...]
}

[...]

}

Altren

10-03-2011 21:19:00

eventRequestDrop is request for you, and it asks if that container accept drop or not. You should not change container when it ask how to draw something. If you really need to reset drag when you move mouse over some widget call resetDrag not inside this request.