App: add signalChanged to Property

For more efficient tracking of single property changes
This commit is contained in:
Zheng, Lei
2019-10-23 07:22:33 +08:00
committed by Chris Hennes
parent 64053912b1
commit 9933d4fbce
2 changed files with 12 additions and 1 deletions

View File

@@ -32,6 +32,7 @@
#include "ObjectIdentifier.h"
#include "PropertyContainer.h"
#include <Base/Exception.h>
#include <Base/Tools.h>
#include "Application.h"
#include "DocumentObject.h"
@@ -212,8 +213,13 @@ void Property::setReadOnly(bool readOnly)
void Property::hasSetValue(void)
{
PropertyCleaner guard(this);
if (father)
if (father) {
father->onChanged(this);
if(!testStatus(Busy)) {
Base::BitsetLocker<decltype(StatusBits)> guard(StatusBits,Busy);
signalChanged(*this);
}
}
StatusBits.set(Touched);
}

View File

@@ -31,6 +31,7 @@
#include <boost/any.hpp>
#include <string>
#include <bitset>
#include <boost/signals2.hpp>
namespace Py {
class Object;
@@ -75,6 +76,7 @@ public:
// relevant for the container using it
EvalOnRestore = 14, // In case of expression binding, evaluate the
// expression on restore and touch the object on value change.
Busy = 15, // internal use to avoid recursive signaling
// The following bits are corresponding to PropertyType set when the
// property added. These types are meant to be static, and cannot be
@@ -269,6 +271,9 @@ private:
private:
PropertyContainer *father;
const char *myName;
public:
boost::signals2::signal<void (const App::Property&)> signalChanged;
};