fix infinite recursion in case of non-DAG documents

This commit is contained in:
wmayer
2018-08-06 18:52:48 +02:00
parent cc737339ad
commit 2a36f5c944
3 changed files with 27 additions and 1 deletions

View File

@@ -165,6 +165,20 @@ private:
// ----------------------------------------------------------------------------
class StateLocker
{
public:
StateLocker(bool& flag, bool st = true) : lock(flag), state(st)
{ lock = state; }
~StateLocker()
{ lock = !state; }
private:
bool& lock;
bool state;
};
// ----------------------------------------------------------------------------
class ConnectionBlocker {
typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
bool b;

View File

@@ -32,6 +32,7 @@
#include "Command.h"
#include "Application.h"
#include "Document.h"
#include <Base/Tools.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/GroupExtension.h>
@@ -43,7 +44,7 @@ using namespace Gui;
EXTENSION_PROPERTY_SOURCE(Gui::ViewProviderGroupExtension, Gui::ViewProviderExtension)
ViewProviderGroupExtension::ViewProviderGroupExtension() : visible(false)
ViewProviderGroupExtension::ViewProviderGroupExtension() : visible(false), guard(false)
{
initExtensionType(ViewProviderGroupExtension::getExtensionClassTypeId());
}
@@ -116,6 +117,11 @@ std::vector< App::DocumentObject* > ViewProviderGroupExtension::extensionClaimCh
void ViewProviderGroupExtension::extensionShow(void) {
// avoid possible infinite recursion
if (guard)
return;
Base::StateLocker lock(guard);
// when reading the Visibility property from file then do not hide the
// objects of this group because they have stored their visibility status, too
if (!getExtendedViewProvider()->isRestoring() && !this->visible) {
@@ -136,6 +142,11 @@ void ViewProviderGroupExtension::extensionShow(void) {
void ViewProviderGroupExtension::extensionHide(void) {
// avoid possible infinite recursion
if (guard)
return;
Base::StateLocker lock(guard);
// when reading the Visibility property from file then do not hide the
// objects of this group because they have stored their visibility status, too
if (!getExtendedViewProvider()->isRestoring() && this->visible) {

View File

@@ -54,6 +54,7 @@ public:
private:
bool visible; // helper variable
bool guard;
std::vector<ViewProvider*> nodes;
};