Merge pull request #24178 from FlachyJoe/non-recursive-freeze

Core: Freeze state enhancement
This commit is contained in:
Chris Hennes
2025-09-30 13:01:15 -05:00
committed by GitHub
3 changed files with 35 additions and 7 deletions

View File

@@ -228,6 +228,19 @@ void DocumentObject::touch(bool noRecompute)
void DocumentObject::freeze()
{
StatusBits.set(ObjectStatus::Freeze);
// store read-only property names
this->readOnlyProperties.clear();
std::vector<std::pair<const char*, Property*>> list;
static_cast<App::PropertyContainer*>(this)->getPropertyNamedList(list);
for (auto pair: list){
if (pair.second->isReadOnly()){
this->readOnlyProperties.push_back(pair.first);
} else {
pair.second->setReadOnly(true);
}
}
// use the signalTouchedObject to refresh the Gui
if (_pDoc) {
_pDoc->signalTouchedObject(*this);
@@ -241,6 +254,17 @@ void DocumentObject::freeze()
void DocumentObject::unfreeze(bool noRecompute)
{
StatusBits.reset(ObjectStatus::Freeze);
// reset read-only property status
std::vector<std::pair<const char*, Property*>> list;
static_cast<App::PropertyContainer*>(this)->getPropertyNamedList(list);
for (auto pair: list){
if (! std::count(readOnlyProperties.begin(), readOnlyProperties.end(), pair.first)){
pair.second->setReadOnly(false);
}
}
touch(noRecompute);
}
@@ -840,6 +864,10 @@ DocumentObject::onProposedLabelChange(std::string& newLabel)
void DocumentObject::onEarlyChange(const Property* prop)
{
if (isFreezed() && prop != &Visibility) {
return;
}
if (GetApplication().isClosingAll()) {
return;
}

View File

@@ -110,6 +110,11 @@ class AppExport DocumentObject: public App::TransactionalObject
{
PROPERTY_HEADER_WITH_OVERRIDE(App::DocumentObject);
private:
// store read-only property names at freeze
// in order to retablish correct status at unfreeze
std::vector<const char*> readOnlyProperties;
public:
PropertyString Label;
PropertyString Label2;

View File

@@ -176,19 +176,14 @@ void StdCmdToggleFreeze::activated(int iMsg)
Command::openCommand(QT_TRANSLATE_NOOP("Command", "Toggle freeze"));
for (Gui::SelectionSingleton::SelObj& sel : sels) {
App::DocumentObject* obj = sel.pObject;
if (!obj)
if (!obj) {
continue;
}
if (obj->isFreezed()){
obj->unfreeze();
for (auto child : obj->getInListRecursive())
child->unfreeze();
for (auto child : obj->getOutListRecursive())
child->unfreeze();
} else {
obj->freeze();
for (auto parent : obj->getOutListRecursive())
parent->freeze();
}
}