Restore "Fix for SPE-1657 : [LINUX - GTK3] Crash when change position of part in sidebar" but with fix of caused issue
This commit is contained in:
parent
6894af24ac
commit
657737d4ff
@ -1192,6 +1192,13 @@ void ObjectList::key_event(wxKeyEvent& event)
|
||||
|
||||
void ObjectList::OnBeginDrag(wxDataViewEvent &event)
|
||||
{
|
||||
if (m_is_editing_started)
|
||||
m_is_editing_started = false;
|
||||
#ifdef __WXGTK__
|
||||
const auto renderer = dynamic_cast<BitmapTextRenderer*>(GetColumn(colName)->GetRenderer());
|
||||
renderer->FinishEditing();
|
||||
#endif
|
||||
|
||||
const wxDataViewItem item(event.GetItem());
|
||||
|
||||
const bool mult_sel = multiple_selection();
|
||||
@ -1225,18 +1232,11 @@ void ObjectList::OnBeginDrag(wxDataViewEvent &event)
|
||||
m_objects_model->GetInstanceIdByItem(item),
|
||||
type);
|
||||
|
||||
/* Under MSW or OSX, DnD moves an item to the place of another selected item
|
||||
* But under GTK, DnD moves an item between another two items.
|
||||
* And as a result - call EVT_CHANGE_SELECTION to unselect all items.
|
||||
* To prevent such behavior use m_prevent_list_events
|
||||
**/
|
||||
m_prevent_list_events = true;//it's needed for GTK
|
||||
|
||||
/* Under GTK, DnD requires to the wxTextDataObject been initialized with some valid value,
|
||||
* so set some nonempty string
|
||||
*/
|
||||
wxTextDataObject* obj = new wxTextDataObject;
|
||||
obj->SetText("Some text");//it's needed for GTK
|
||||
obj->SetText(mult_sel ? "SomeText" : m_objects_model->GetItemName(item));//it's needed for GTK
|
||||
|
||||
event.SetDataObject(obj);
|
||||
event.SetDragFlags(wxDrag_DefaultMove); // allows both copy and move;
|
||||
@ -1300,10 +1300,8 @@ void ObjectList::OnDropPossible(wxDataViewEvent &event)
|
||||
{
|
||||
const wxDataViewItem& item = event.GetItem();
|
||||
|
||||
if (!can_drop(item)) {
|
||||
if (!can_drop(item))
|
||||
event.Veto();
|
||||
m_prevent_list_events = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::OnDrop(wxDataViewEvent &event)
|
||||
@ -1317,6 +1315,13 @@ void ObjectList::OnDrop(wxDataViewEvent &event)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Under MSW or OSX, DnD moves an item to the place of another selected item
|
||||
* But under GTK, DnD moves an item between another two items.
|
||||
* And as a result - call EVT_CHANGE_SELECTION to unselect all items.
|
||||
* To prevent such behavior use m_prevent_list_events
|
||||
**/
|
||||
m_prevent_list_events = true;//it's needed for GTK
|
||||
|
||||
if (m_dragged_data.type() == itInstance)
|
||||
{
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(),_(L("Instances to Separated Objects")));
|
||||
@ -4841,6 +4846,9 @@ void ObjectList::OnEditingStarted(wxDataViewEvent &event)
|
||||
|
||||
void ObjectList::OnEditingDone(wxDataViewEvent &event)
|
||||
{
|
||||
if (!m_is_editing_started)
|
||||
return;
|
||||
|
||||
m_is_editing_started = false;
|
||||
if (event.GetColumn() != colName)
|
||||
return;
|
||||
|
@ -1042,6 +1042,16 @@ int ObjectDataViewModel::GetItemIdByLayerRange(const int obj_idx, const t_layer
|
||||
return GetLayerIdByItem(item);
|
||||
}
|
||||
|
||||
wxString ObjectDataViewModel::GetItemName(const wxDataViewItem& item) const
|
||||
{
|
||||
if (!item.IsOk())
|
||||
return wxEmptyString;
|
||||
ObjectDataViewModelNode* node = static_cast<ObjectDataViewModelNode*>(item.GetID());
|
||||
if (!node)
|
||||
return wxEmptyString;
|
||||
return node->GetName();
|
||||
}
|
||||
|
||||
int ObjectDataViewModel::GetIdByItem(const wxDataViewItem& item) const
|
||||
{
|
||||
if(!item.IsOk())
|
||||
|
@ -311,6 +311,7 @@ public:
|
||||
wxDataViewItem GetItemByLayerId(int obj_idx, int layer_idx);
|
||||
wxDataViewItem GetItemByLayerRange(const int obj_idx, const t_layer_height_range& layer_range);
|
||||
int GetItemIdByLayerRange(const int obj_idx, const t_layer_height_range& layer_range);
|
||||
wxString GetItemName(const wxDataViewItem& item) const;
|
||||
int GetIdByItem(const wxDataViewItem& item) const;
|
||||
int GetIdByItemAndType(const wxDataViewItem& item, const ItemType type) const;
|
||||
int GetObjectIdByItem(const wxDataViewItem& item) const;
|
||||
|
Loading…
Reference in New Issue
Block a user