From c44463862027ea8dff23e6014244a8603db0d3bf Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 7 Dec 2024 12:51:10 +0100 Subject: [PATCH] Gui: Rename ViewProviderDatum::getRoot() to ViewProviderDatum::getDatumRoot() Before the change the compiler raised the warning: 'Gui::ViewProviderDatum::getRoot' hides overloaded virtual function [-Werror,-Woverloaded-virtual] In the base class the method getRoot() is declared as const while in ViewProviderDatum it's not and that's why it's considered as an overloaded method. However, this signature causes two problems: 1. In the client code it's not always clear which version of getRoot() should be called 2. It violates const-correctness So, trying to declare the method ViewProviderDatum::getRoot() as const it now overrides the method of the base class (and fixes the warning) but this doesn't lead to the expected result: See https://forum.freecad.org/viewtopic.php?p=796064#p796064 The other option is to rename the method. And this gives the expected result now. --- src/Gui/ViewProviderDatum.h | 4 ++-- src/Gui/ViewProviderLine.cpp | 2 +- src/Gui/ViewProviderPlane.cpp | 2 +- src/Gui/ViewProviderPoint.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Gui/ViewProviderDatum.h b/src/Gui/ViewProviderDatum.h index 857037ae286c..e2c25559d0ff 100644 --- a/src/Gui/ViewProviderDatum.h +++ b/src/Gui/ViewProviderDatum.h @@ -44,10 +44,10 @@ namespace Gui ~ViewProviderDatum() override; /// Get point derived classes will add their specific stuff - SoSeparator* getRoot() { return pRoot; } + SoSeparator* getDatumRoot() const { return pRoot; } /// Get pointer to the text label associated with the feature - SoText2* getLabel() { return pLabel; } + SoText2* getLabel() const { return pLabel; } void attach(App::DocumentObject*) override; std::vector getDisplayModes() const override; diff --git a/src/Gui/ViewProviderLine.cpp b/src/Gui/ViewProviderLine.cpp index a3d99cf640fb..bcc464da5854 100644 --- a/src/Gui/ViewProviderLine.cpp +++ b/src/Gui/ViewProviderLine.cpp @@ -94,7 +94,7 @@ void ViewProviderLine::attach(App::DocumentObject *obj) { // indexes used to create the edges static const int32_t lines[4] = { 0, 1, -1 }; - SoSeparator *sep = getRoot(); + SoSeparator *sep = getDatumRoot(); auto pCoords = new SoCoordinate3 (); pCoords->point.setNum (2); diff --git a/src/Gui/ViewProviderPlane.cpp b/src/Gui/ViewProviderPlane.cpp index 7c567e4505de..25e6fe577f63 100644 --- a/src/Gui/ViewProviderPlane.cpp +++ b/src/Gui/ViewProviderPlane.cpp @@ -114,7 +114,7 @@ void ViewProviderPlane::attach(App::DocumentObject * obj) { // indexes used to create the edges static const int32_t lines[6] = { 0, 1, 2, 3, 0, -1 }; - SoSeparator* sep = getRoot(); + SoSeparator* sep = getDatumRoot(); auto pCoords = new SoCoordinate3(); pCoords->point.setNum(4); diff --git a/src/Gui/ViewProviderPoint.cpp b/src/Gui/ViewProviderPoint.cpp index edcde697261c..3e87d23bfc0a 100644 --- a/src/Gui/ViewProviderPoint.cpp +++ b/src/Gui/ViewProviderPoint.cpp @@ -52,7 +52,7 @@ void ViewProviderPoint::attach(App::DocumentObject * obj) { // The coordinates for the point (single vertex at the origin) static const SbVec3f point = SbVec3f(0, 0, 0); - SoSeparator* sep = getRoot(); + SoSeparator* sep = getDatumRoot(); auto pCoords = new SoCoordinate3(); pCoords->point.setNum(1);