From 0f53f2195d8be52ba6fa092a34188c68c7a07950 Mon Sep 17 00:00:00 2001 From: bgbsww Date: Sat, 14 Sep 2024 21:45:52 -0400 Subject: [PATCH] Add override flag for recomputes; set it in relevant tests with old files. --- src/App/Document.h | 2 +- src/Gui/Application.cpp | 17 +++++++++++------ src/Gui/Application.h | 2 +- src/Gui/Document.cpp | 1 + src/Mod/CAM/Tests/TestCAMSanity.py | 2 ++ src/Mod/CAM/Tests/TestPathAdaptive.py | 2 ++ src/Mod/CAM/Tests/TestPathDrillable.py | 2 ++ src/Mod/CAM/Tests/TestPathOpUtil.py | 2 ++ src/Mod/CAM/Tests/TestPathPost.py | 11 +++++++++++ src/Mod/CAM/Tests/TestPathProfile.py | 2 ++ src/Mod/CAM/Tests/TestPathToolController.py | 2 ++ src/Mod/Part/App/PropertyTopoShape.cpp | 6 +++--- .../PartDesignTests/TestInvoluteGear.py | 2 ++ .../PartDesignTests/TestMultiTransform.py | 2 ++ 14 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/App/Document.h b/src/App/Document.h index 76bc7da902..c49434ff7b 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -77,7 +77,7 @@ public: RestoreError = 10, LinkStampChanged = 11, // Indicates during restore time if any linked document's time stamp has changed IgnoreErrorOnRecompute = 12, // Don't report errors if the recompute failed - RecomputeOnRestore = 13, // Mark pending recompute on restore for migration purpose + RecomputeOnRestore = 13, // Mark pending recompute on restore for migration purposes }; /** @name Properties */ diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 4ec9e6029f..3815021fd6 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -979,8 +979,8 @@ void Application::slotShowHidden(const App::Document& Doc) signalShowHidden(*doc->second); } -void Application::slotFinishRestoreDocument(const App::Document& Doc) { - Doc; +void Application::slotFinishRestoreDocument([[maybe_unused]] const App::Document& Doc) { + // Quietly gnore the doc parameter and check across all documents. std::vector docs; for (auto doc: App::GetApplication().getDocuments()) { if (doc->testStatus(App::Document::RecomputeOnRestore)) { @@ -988,14 +988,19 @@ void Application::slotFinishRestoreDocument(const App::Document& Doc) { doc->setStatus(App::Document::RecomputeOnRestore, false); } } - if (docs.empty()) + // Certain tests want to use very old .FCStd files. We should not prompt during those tests, so this + // allows them to 'FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True")` + const std::map& Map = App::Application::Config(); + auto value = Map.find("SuppressRecomputeRequiredDialog"); + bool skip = value not_eq Map.end() and not value->second.empty(); // Any non empty string is true. + if (docs.empty() || skip ) return; WaitCursor wc; wc.restoreCursor(); - auto res = QMessageBox::warning(getMainWindow(), QObject::tr("Recompution required"), - QObject::tr("Some document(s) require recomputation for migration purpose. " + auto res = QMessageBox::warning(getMainWindow(), QObject::tr("Recomputation required"), + QObject::tr("Some document(s) require recomputation for migration purposes. " "It is highly recommended to perform a recomputation before " - "any modification to avoid compatibility problem.\n\n" + "any modification to avoid compatibility problems.\n\n" "Do you want to recompute now?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (res != QMessageBox::Yes) diff --git a/src/Gui/Application.h b/src/Gui/Application.h index 5a87d3c100..57171c158f 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -131,7 +131,7 @@ public: boost::signals2::signal signalRefreshWorkbenches; /// signal on show hidden items boost::signals2::signal signalShowHidden; - /// signal on document open complete + /// signal on document restore complete boost::signals2::signal signalFinishRestoreDocument; /// signal on activating view boost::signals2::signal signalActivateView; diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 045573a337..cadc6121a0 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -185,6 +185,7 @@ Document::Document(App::Document* pcDocument,Application * app) (std::bind(&Gui::Document::slotFinishRestoreDocument, this, sp::_1)); d->connectShowHidden = App::GetApplication().signalShowHidden.connect (std::bind(&Gui::Document::slotShowHidden, this, sp::_1)); + d->connectChangePropertyEditor = pcDocument->signalChangePropertyEditor.connect (std::bind(&Gui::Document::slotChangePropertyEditor, this, sp::_1, sp::_2)); d->connectChangeDocument = d->_pcDocument->signalChanged.connect // use the same slot function diff --git a/src/Mod/CAM/Tests/TestCAMSanity.py b/src/Mod/CAM/Tests/TestCAMSanity.py index 0289b23f79..7b710617eb 100644 --- a/src/Mod/CAM/Tests/TestCAMSanity.py +++ b/src/Mod/CAM/Tests/TestCAMSanity.py @@ -42,7 +42,9 @@ from Tests.PathTestUtils import PathTestBase class TestCAMSanity(PathTestBase): @classmethod def setUpClass(cls): + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.doc = FreeCAD.open(FreeCAD.getHomePath() + "/Mod/CAM/Tests/boxtest.fcstd") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") cls.job = cls.doc.getObject("Job") @classmethod diff --git a/src/Mod/CAM/Tests/TestPathAdaptive.py b/src/Mod/CAM/Tests/TestPathAdaptive.py index 68d5b75993..bce4a4c337 100644 --- a/src/Mod/CAM/Tests/TestPathAdaptive.py +++ b/src/Mod/CAM/Tests/TestPathAdaptive.py @@ -52,7 +52,9 @@ class TestPathAdaptive(PathTestBase): def initClass(cls): # Open existing FreeCAD document with test geometry cls.needsInit = False + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.doc = FreeCAD.open(FreeCAD.getHomePath() + "Mod/CAM/Tests/test_adaptive.fcstd") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") # Create Job object, adding geometry objects from file opened above cls.job = PathJob.Create("Job", [cls.doc.Fusion], None) diff --git a/src/Mod/CAM/Tests/TestPathDrillable.py b/src/Mod/CAM/Tests/TestPathDrillable.py index 9e0df98838..ec63e99b62 100644 --- a/src/Mod/CAM/Tests/TestPathDrillable.py +++ b/src/Mod/CAM/Tests/TestPathDrillable.py @@ -35,7 +35,9 @@ else: class TestPathDrillable(PathTestUtils.PathTestBase): def setUp(self): + App.ConfigSet("SuppressRecomputeRequiredDialog", "True") self.doc = App.open(App.getHomePath() + "/Mod/CAM/Tests/Drilling_1.FCStd") + App.ConfigSet("SuppressRecomputeRequiredDialog", "") self.obj = self.doc.getObject("Pocket011") def tearDown(self): diff --git a/src/Mod/CAM/Tests/TestPathOpUtil.py b/src/Mod/CAM/Tests/TestPathOpUtil.py index 028e0f7d8b..d7ec189d25 100644 --- a/src/Mod/CAM/Tests/TestPathOpUtil.py +++ b/src/Mod/CAM/Tests/TestPathOpUtil.py @@ -84,7 +84,9 @@ def wireMarkers(wire): class TestPathOpUtil(PathTestUtils.PathTestBase): @classmethod def setUpClass(cls): + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.doc = FreeCAD.openDocument(DOC) + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") @classmethod def tearDownClass(cls): diff --git a/src/Mod/CAM/Tests/TestPathPost.py b/src/Mod/CAM/Tests/TestPathPost.py index ebb7c26e35..469c371d3c 100644 --- a/src/Mod/CAM/Tests/TestPathPost.py +++ b/src/Mod/CAM/Tests/TestPathPost.py @@ -86,6 +86,8 @@ class TestFileNameGenerator(unittest.TestCase): # cls.doc = FreeCAD.open(FreeCAD.getHomePath() + "/Mod/CAM/Tests/boxtest.fcstd") # cls.job = cls.doc.getObject("Job") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") + cls.testfile = FreeCAD.getHomePath() + "Mod/CAM/Tests/test_filenaming.fcstd" cls.testfilepath, cls.testfilename = os.path.split(cls.testfile) cls.testfilename, cls.ext = os.path.splitext(cls.testfilename) @@ -98,6 +100,7 @@ class TestFileNameGenerator(unittest.TestCase): @classmethod def tearDownClass(cls): FreeCAD.closeDocument(cls.doc.Name) + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") # def test010(self): # self.job.PostProcessorOutputFile = "" @@ -272,12 +275,14 @@ class TestFileNameGenerator(unittest.TestCase): class TestResolvingPostProcessorName(unittest.TestCase): @classmethod def setUpClass(cls): + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.doc = FreeCAD.open(FreeCAD.getHomePath() + "/Mod/CAM/Tests/boxtest.fcstd") cls.job = cls.doc.getObject("Job") @classmethod def tearDownClass(cls): FreeCAD.closeDocument(cls.doc.Name) + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") def setUp(self): pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/CAM") @@ -327,12 +332,14 @@ class TestPostProcessorFactory(unittest.TestCase): @classmethod def setUpClass(cls): + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.doc = FreeCAD.open(FreeCAD.getHomePath() + "/Mod/CAM/Tests/boxtest.fcstd") cls.job = cls.doc.getObject("Job") @classmethod def tearDownClass(cls): FreeCAD.closeDocument(cls.doc.Name) + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") def setUp(self): pass @@ -359,12 +366,14 @@ class TestPostProcessorClass(unittest.TestCase): @classmethod def setUpClass(cls): + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.doc = FreeCAD.open(FreeCAD.getHomePath() + "/Mod/CAM/Tests/boxtest.fcstd") cls.job = cls.doc.getObject("Job") @classmethod def tearDownClass(cls): FreeCAD.closeDocument(cls.doc.Name) + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") def setUp(self): pass @@ -603,8 +612,10 @@ class TestBuildPostList(unittest.TestCase): @classmethod def setUpClass(cls): + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.testfile = FreeCAD.getHomePath() + "Mod/CAM/Tests/test_filenaming.fcstd" cls.doc = FreeCAD.open(cls.testfile) + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") cls.job = cls.doc.getObjectsByLabel("MainJob")[0] @classmethod diff --git a/src/Mod/CAM/Tests/TestPathProfile.py b/src/Mod/CAM/Tests/TestPathProfile.py index f41cb7cbf8..d6be87bb1f 100644 --- a/src/Mod/CAM/Tests/TestPathProfile.py +++ b/src/Mod/CAM/Tests/TestPathProfile.py @@ -54,7 +54,9 @@ class TestPathProfile(PathTestBase): def initClass(cls): # Open existing FreeCAD document with test geometry cls.needsInit = False + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") cls.doc = FreeCAD.open(FreeCAD.getHomePath() + "Mod/CAM/Tests/test_profile.fcstd") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") # Create Job object, adding geometry objects from file opened above cls.job = PathJob.Create("Job", [cls.doc.Body], None) diff --git a/src/Mod/CAM/Tests/TestPathToolController.py b/src/Mod/CAM/Tests/TestPathToolController.py index af4b9717ed..7f6c76a040 100644 --- a/src/Mod/CAM/Tests/TestPathToolController.py +++ b/src/Mod/CAM/Tests/TestPathToolController.py @@ -31,9 +31,11 @@ from Tests.PathTestUtils import PathTestBase class TestPathToolController(PathTestBase): def setUp(self): self.doc = FreeCAD.newDocument("TestPathToolController") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") def tearDown(self): FreeCAD.closeDocument(self.doc.Name) + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") def createTool(self, name="t1", diameter=1.75): attrs = { diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index 060de241b9..17c4123325 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -389,10 +389,10 @@ void PropertyPartShape::Restore(Base::XMLReader &reader) } } } else if(owner && !owner->getDocument()->testStatus(App::Document::PartialDoc)) { - // Toponaming 09/2024: Original code has a whole infrastructure of document parameters we aren't bring in: + // Toponaming 09/2024: Original code has an infrastructure for document parameters we aren't bringing in: // if(App::DocumentParams::getWarnRecomputeOnRestore()) { - // However, this warning appears on all files without element maps, and is now superceded by a user dialog - // after loading that is triggered by any addRecomputeObject() + // However, this warning appeared on all files without element maps, and is now superseded by a user dialog + // after loading that is triggered by any call to addRecomputeObject() // FC_WARN("Pending recompute for generating element map: " << owner->getFullName()); owner->getDocument()->addRecomputeObject(owner); } diff --git a/src/Mod/PartDesign/PartDesignTests/TestInvoluteGear.py b/src/Mod/PartDesign/PartDesignTests/TestInvoluteGear.py index c3e75193af..13e6e463fa 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestInvoluteGear.py +++ b/src/Mod/PartDesign/PartDesignTests/TestInvoluteGear.py @@ -34,8 +34,10 @@ FIXTURE_PATH = pathlib.Path(__file__).parent / "Fixtures" class TestInvoluteGear(unittest.TestCase): def setUp(self): self.Doc = FreeCAD.newDocument("PartDesignTestInvoluteGear") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") def tearDown(self): + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") FreeCAD.closeDocument(self.Doc.Name) def testDefaultGearProfile(self): diff --git a/src/Mod/PartDesign/PartDesignTests/TestMultiTransform.py b/src/Mod/PartDesign/PartDesignTests/TestMultiTransform.py index 272f708284..fff403484d 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestMultiTransform.py +++ b/src/Mod/PartDesign/PartDesignTests/TestMultiTransform.py @@ -29,6 +29,7 @@ App = FreeCAD class TestMultiTransform(unittest.TestCase): def setUp(self): self.Doc = FreeCAD.newDocument("PartDesignTestMultiTransform") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True") def testMultiTransform(self): self.Body = self.Doc.addObject('PartDesign::Body','Body') @@ -132,5 +133,6 @@ class TestMultiTransform(unittest.TestCase): def tearDown(self): #closing doc FreeCAD.closeDocument("PartDesignTestMultiTransform") + FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "") #print ("omit closing document for debugging")