Skip to content

Commit

Permalink
Gui: check object existence before SelBack/Forward
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed May 3, 2020
1 parent 8be2c08 commit e6fc155
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
42 changes: 29 additions & 13 deletions src/Gui/Selection.cpp
Expand Up @@ -1075,12 +1075,12 @@ void SelectionSingleton::selStackPush(bool clearForward, bool overwrite) {
_SelStackBack.pop_front();
SelStackItem item;
for(auto &sel : _SelList)
item.insert({sel.DocName,sel.FeatName,sel.SubName});
item.emplace(sel.DocName.c_str(),sel.FeatName.c_str(),sel.SubName.c_str());
if(_SelStackBack.size() && _SelStackBack.back()==item)
return;
if(!overwrite || _SelStackBack.empty())
_SelStackBack.emplace_back();
_SelStackBack.back().swap(item);
_SelStackBack.back() = std::move(item);
}

void SelectionSingleton::selStackGoBack(int count) {
Expand All @@ -1091,25 +1091,30 @@ void SelectionSingleton::selStackGoBack(int count) {
if(_SelList.size()) {
selStackPush(false,true);
clearCompleteSelection();
}
} else
--count;
for(int i=0;i<count;++i) {
_SelStackForward.push_front(_SelStackBack.back());
_SelStackForward.push_front(std::move(_SelStackBack.back()));
_SelStackBack.pop_back();
}
std::deque<SelStackItem> tmpStack;
_SelStackForward.swap(tmpStack);
while(_SelStackBack.size()) {
bool found = false;
for(auto &n : _SelStackBack.back()) {
if(addSelection(n[0].c_str(), n[1].c_str(), n[2].c_str()))
for(auto &sobjT : _SelStackBack.back()) {
if(sobjT.getSubObject()) {
addSelection(sobjT.getDocumentName().c_str(),
sobjT.getObjectName().c_str(),
sobjT.getSubName().c_str());
found = true;
}
}
if(found)
break;
tmpStack.push_front(_SelStackBack.back());
tmpStack.push_front(std::move(_SelStackBack.back()));
_SelStackBack.pop_back();
}
_SelStackForward.swap(tmpStack);
_SelStackForward = std::move(tmpStack);
getMainWindow()->updateActions();
}

Expand All @@ -1130,16 +1135,20 @@ void SelectionSingleton::selStackGoForward(int count) {
_SelStackForward.swap(tmpStack);
while(1) {
bool found = false;
for(auto &n : _SelStackBack.back()) {
if(addSelection(n[0].c_str(), n[1].c_str(), n[2].c_str()))
for(auto &sobjT : _SelStackBack.back()) {
if(sobjT.getSubObject()) {
addSelection(sobjT.getDocumentName().c_str(),
sobjT.getObjectName().c_str(),
sobjT.getSubName().c_str());
found = true;
}
}
if(found || tmpStack.empty())
break;
_SelStackBack.push_back(tmpStack.front());
tmpStack.pop_front();
}
_SelStackForward.swap(tmpStack);
_SelStackForward = std::move(tmpStack);
getMainWindow()->updateActions();
}

Expand All @@ -1159,10 +1168,17 @@ std::vector<SelectionObject> SelectionSingleton::selStackGet(
}

std::list<_SelObj> selList;
for(auto &s : *item) {
for(auto &sobjT : *item) {
_SelObj sel;
if(checkSelection(s[0].c_str(),s[1].c_str(),s[2].c_str(),0,sel,&selList)==0)
if(checkSelection(sobjT.getDocumentName().c_str(),
sobjT.getObjectName().c_str(),
sobjT.getSubName().c_str(),
0,
sel,
&selList)==0)
{
selList.push_back(sel);
}
}

return getObjectList(pDocName,App::DocumentObject::getClassTypeId(),selList,resolve);
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/Selection.h
Expand Up @@ -703,7 +703,7 @@ class GuiExport SelectionSingleton : public Base::Subject<const SelectionChanges
mutable std::list<_SelObj> _PickedList;
bool _needPickedList;

typedef std::set<std::array<std::string,3> > SelStackItem;
typedef std::set<App::SubObjectT> SelStackItem;
std::deque<SelStackItem> _SelStackBack;
std::deque<SelStackItem> _SelStackForward;

Expand Down

0 comments on commit e6fc155

Please sign in to comment.