Introduce object freeze (#12580)
* Introduce object freeze * do nothing at property change
This commit is contained in:
committed by
GitHub
parent
b9f0d3b680
commit
c53d5fbf9d
@@ -213,6 +213,28 @@ void DocumentObject::touch(bool noRecompute)
|
||||
_pDoc->signalTouchedObject(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set this document object freezed.
|
||||
* A freezed document object does not recompute ever.
|
||||
*/
|
||||
void DocumentObject::freeze()
|
||||
{
|
||||
StatusBits.set(ObjectStatus::Freeze);
|
||||
// use the signalTouchedObject to refresh the Gui
|
||||
if (_pDoc)
|
||||
_pDoc->signalTouchedObject(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set this document object unfreezed.
|
||||
* A freezed document object does not recompute ever.
|
||||
*/
|
||||
void DocumentObject::unfreeze(bool noRecompute)
|
||||
{
|
||||
StatusBits.set(ObjectStatus::Freeze, false);
|
||||
touch(noRecompute);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check whether the document object is touched or not.
|
||||
* @return true if document object is touched, false if not.
|
||||
@@ -240,6 +262,9 @@ void DocumentObject::enforceRecompute()
|
||||
*/
|
||||
bool DocumentObject::mustRecompute() const
|
||||
{
|
||||
if (StatusBits.test(ObjectStatus::Freeze))
|
||||
return false;
|
||||
|
||||
if (StatusBits.test(ObjectStatus::Enforce))
|
||||
return true;
|
||||
|
||||
@@ -726,6 +751,9 @@ void DocumentObject::onBeforeChange(const Property* prop)
|
||||
/// get called by the container when a Property was changed
|
||||
void DocumentObject::onChanged(const Property* prop)
|
||||
{
|
||||
if (isFreezed())
|
||||
return;
|
||||
|
||||
if(GetApplication().isClosingAll())
|
||||
return;
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ enum ObjectStatus {
|
||||
PendingTransactionUpdate = 18, // mark that the object expects a call to onUndoRedoFinished() after transaction is finished.
|
||||
RecomputeExtension = 19, // mark the object to recompute its extensions
|
||||
TouchOnColorChange = 20, // inform view provider touch object on color change
|
||||
Freeze = 21, // do not recompute ever
|
||||
};
|
||||
|
||||
/** Return object for feature execution
|
||||
@@ -177,6 +178,12 @@ public:
|
||||
bool isRestoring() const {return StatusBits.test(ObjectStatus::Restore);}
|
||||
/// returns true if this objects is currently removed from the document
|
||||
bool isRemoving() const {return StatusBits.test(ObjectStatus::Remove);}
|
||||
/// set this document object freezed (prevent recomputation)
|
||||
void freeze();
|
||||
/// set this document object unfreezed (and touch it)
|
||||
void unfreeze(bool noRecompute=false);
|
||||
/// returns true if this objects is currently freezed
|
||||
bool isFreezed() const {return StatusBits.test(ObjectStatus::Freeze);}
|
||||
/// return the status bits
|
||||
unsigned long getStatus() const {return StatusBits.to_ulong();}
|
||||
bool testStatus(ObjectStatus pos) const {return StatusBits.test(size_t(pos));}
|
||||
|
||||
Reference in New Issue
Block a user