Fix clang compiler warnings:

+ fix -Winconsistent-missing-override
+ fix -Wunused-variable
+ fix -Wbraced-scalar-init
+ fix -Wparentheses (View3DInventorViewer::checkGroupOnTop: operator '?:' has lower precedence than '+'; '+' will be evaluated first)
+ fix -Wundefined-bool-conversion (MainWindow::updateActions)
+ suppress -Woverloaded-virtual but fix later
This commit is contained in:
wmayer
2019-08-09 14:50:53 +02:00
parent 3e6ae0d027
commit 5172c3bc08
16 changed files with 128 additions and 118 deletions

View File

@@ -191,7 +191,7 @@ public:
template <class ViewProviderT>
class ViewProviderPythonFeatureT : public ViewProviderT
{
PROPERTY_HEADER(Gui::ViewProviderPythonFeatureT<ViewProviderT>);
PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderPythonFeatureT<ViewProviderT>);
public:
/// constructor.
@@ -205,37 +205,37 @@ public:
}
// Returns the icon
QIcon getIcon() const {
QIcon getIcon() const override {
QIcon icon = imp->getIcon();
if (icon.isNull())
icon = ViewProviderT::getIcon();
return icon;
}
std::vector<App::DocumentObject*> claimChildren() const {
std::vector<App::DocumentObject*> claimChildren() const override {
return imp->claimChildren(ViewProviderT::claimChildren());
}
/** @name Nodes */
//@{
virtual SoSeparator* getRoot() {
virtual SoSeparator* getRoot() override {
return ViewProviderT::getRoot();
}
virtual SoSeparator* getFrontRoot() const {
virtual SoSeparator* getFrontRoot() const override {
return ViewProviderT::getFrontRoot();
}
// returns the root node of the Provider (3D)
virtual SoSeparator* getBackRoot() const {
virtual SoSeparator* getBackRoot() const override {
return ViewProviderT::getBackRoot();
}
//@}
/** @name Selection handling */
//@{
virtual bool useNewSelectionModel() const {
virtual bool useNewSelectionModel() const override {
return imp->useNewSelectionModel();
}
virtual bool getElementPicked(const SoPickedPoint *pp, std::string &subname) const {
virtual bool getElementPicked(const SoPickedPoint *pp, std::string &subname) const override {
auto ret = imp->getElementPicked(pp,subname);
if(ret == ViewProviderPythonFeatureImp::NotImplemented)
return ViewProviderT::getElementPicked(pp,subname);
@@ -243,42 +243,42 @@ public:
return true;
return false;
}
virtual std::string getElement(const SoDetail *det) const {
virtual std::string getElement(const SoDetail *det) const override {
std::string name = imp->getElement(det);
if (!name.empty()) return name;
return ViewProviderT::getElement(det);
}
virtual SoDetail* getDetail(const char* name) const {
virtual SoDetail* getDetail(const char* name) const override {
SoDetail* det = imp->getDetail(name);
if (det) return det;
return ViewProviderT::getDetail(name);
}
virtual bool getDetailPath(const char *name, SoFullPath *path, bool append,SoDetail *&det) const {
virtual bool getDetailPath(const char *name, SoFullPath *path, bool append,SoDetail *&det) const override {
auto ret = imp->getDetailPath(name,path,append,det);
if(ret == ViewProviderPythonFeatureImp::NotImplemented)
return ViewProviderT::getDetailPath(name,path,append,det);
return ret == ViewProviderPythonFeatureImp::Accepted;
}
virtual std::vector<Base::Vector3d> getSelectionShape(const char* Element) const {
virtual std::vector<Base::Vector3d> getSelectionShape(const char* Element) const override {
return ViewProviderT::getSelectionShape(Element);
};
//@}
/** @name Update data methods*/
//@{
virtual void attach(App::DocumentObject *obj) {
virtual void attach(App::DocumentObject *obj) override {
// delay loading of the actual attach() method because the Python
// view provider class is not attached yet
ViewProviderT::pcObject = obj;
}
virtual void updateData(const App::Property* prop) {
virtual void updateData(const App::Property* prop) override {
imp->updateData(prop);
ViewProviderT::updateData(prop);
}
virtual void getTaskViewContent(std::vector<Gui::TaskView::TaskContent*>& c) const {
virtual void getTaskViewContent(std::vector<Gui::TaskView::TaskContent*>& c) const override {
ViewProviderT::getTaskViewContent(c);
}
virtual bool onDelete(const std::vector<std::string> & sub) {
virtual bool onDelete(const std::vector<std::string> & sub) override {
bool ok = imp->onDelete(sub);
if (!ok) return ok;
return ViewProviderT::onDelete(sub);
@@ -297,11 +297,11 @@ public:
/** @name Restoring view provider from document load */
//@{
virtual void startRestoring() {
virtual void startRestoring() override {
ViewProviderT::startRestoring();
imp->startRestoring();
}
virtual void finishRestoring() {
virtual void finishRestoring() override {
imp->finishRestoring();
ViewProviderT::finishRestoring();
}
@@ -310,7 +310,7 @@ public:
/** @name Drag and drop */
//@{
/// Returns true if the view provider generally supports dragging objects
virtual bool canDragObjects() const {
virtual bool canDragObjects() const override {
switch (imp->canDragObjects()) {
case ViewProviderPythonFeatureImp::Accepted:
return true;
@@ -321,7 +321,7 @@ public:
}
}
/// Check whether the object can be removed from the view provider by drag and drop
virtual bool canDragObject(App::DocumentObject* obj) const {
virtual bool canDragObject(App::DocumentObject* obj) const override {
switch (imp->canDragObject(obj)) {
case ViewProviderPythonFeatureImp::Accepted:
return true;
@@ -332,7 +332,7 @@ public:
}
}
/// Starts to drag the object
virtual void dragObject(App::DocumentObject* obj) {
virtual void dragObject(App::DocumentObject* obj) override {
App::AutoTransaction committer;
switch (imp->dragObject(obj)) {
case ViewProviderPythonFeatureImp::Accepted:
@@ -343,7 +343,7 @@ public:
}
}
/// Returns true if the view provider generally accepts dropping of objects
virtual bool canDropObjects() const {
virtual bool canDropObjects() const override {
switch (imp->canDropObjects()) {
case ViewProviderPythonFeatureImp::Accepted:
return true;
@@ -354,7 +354,7 @@ public:
}
}
/// Check whether the object can be dropped to the view provider by drag and drop
virtual bool canDropObject(App::DocumentObject* obj) const {
virtual bool canDropObject(App::DocumentObject* obj) const override {
switch (imp->canDropObject(obj)) {
case ViewProviderPythonFeatureImp::Accepted:
return true;
@@ -365,7 +365,7 @@ public:
}
}
/// If the dropped object type is accepted the object will be added as child
virtual void dropObject(App::DocumentObject* obj) {
virtual void dropObject(App::DocumentObject* obj) override {
App::AutoTransaction committer;
switch (imp->dropObject(obj)) {
case ViewProviderPythonFeatureImp::Accepted:
@@ -400,7 +400,7 @@ public:
}
/** Add an object with full quanlified name to the view provider by drag and drop */
virtual std::string dropObjectEx(App::DocumentObject *obj, App::DocumentObject *owner,
const char *subname, const std::vector<std::string> &elements)
const char *subname, const std::vector<std::string> &elements) override
{
App::AutoTransaction committer;
std::string ret;
@@ -418,24 +418,24 @@ public:
/** @name Display methods */
//@{
/// Returns true if the icon must always appear enabled in the tree view
virtual bool isShow() const {
virtual bool isShow() const override {
bool ok = imp->isShow();
if (ok) return ok;
return ViewProviderT::isShow();
}
/// get the default display mode
virtual const char* getDefaultDisplayMode() const {
virtual const char* getDefaultDisplayMode() const override {
return imp->getDefaultDisplayMode();
}
/// returns a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const {
virtual std::vector<std::string> getDisplayModes(void) const override {
std::vector<std::string> modes = ViewProviderT::getDisplayModes();
std::vector<std::string> more_modes = imp->getDisplayModes();
modes.insert(modes.end(), more_modes.begin(), more_modes.end());
return modes;
}
/// set the display mode
virtual void setDisplayMode(const char* ModeName) {
virtual void setDisplayMode(const char* ModeName) override {
std::string mask = imp->setDisplayMode(ModeName);
ViewProviderT::setDisplayMaskMode(mask.c_str());
ViewProviderT::setDisplayMode(ModeName);
@@ -453,7 +453,7 @@ public:
}
}
PyObject* getPyObject() {
PyObject* getPyObject() override {
return ViewProviderT::getPyObject();
}
@@ -462,7 +462,7 @@ public:
}
protected:
virtual void onChanged(const App::Property* prop) {
virtual void onChanged(const App::Property* prop) override {
if (prop == &Proxy) {
imp->init(Proxy.getValue().ptr());
if (ViewProviderT::pcObject && !Proxy.getValue().is(Py::_None())) {
@@ -489,7 +489,7 @@ protected:
}
}
/// is called by the document when the provider goes in edit mode
virtual bool setEdit(int ModNum)
virtual bool setEdit(int ModNum) override
{
switch (imp->setEdit(ModNum)) {
case ViewProviderPythonFeatureImp::Accepted:
@@ -501,7 +501,7 @@ protected:
}
}
/// is called when you lose the edit mode
virtual void unsetEdit(int ModNum)
virtual void unsetEdit(int ModNum) override
{
switch (imp->unsetEdit(ModNum)) {
case ViewProviderPythonFeatureImp::Accepted:
@@ -511,23 +511,23 @@ protected:
return ViewProviderT::unsetEdit(ModNum);
}
}
virtual void setEditViewer(View3DInventorViewer *viewer, int ModNum) {
virtual void setEditViewer(View3DInventorViewer *viewer, int ModNum) override {
if(!imp->setEditViewer(viewer,ModNum))
ViewProviderT::setEditViewer(viewer,ModNum);
}
virtual void unsetEditViewer(View3DInventorViewer *viewer) {
virtual void unsetEditViewer(View3DInventorViewer *viewer) override {
if(!imp->unsetEditViewer(viewer))
ViewProviderT::unsetEditViewer(viewer);
}
virtual std::string getDropPrefix() const {
virtual std::string getDropPrefix() const override {
std::string prefix;
if(!imp->getDropPrefix(prefix))
return ViewProviderT::getDropPrefix();
return prefix;
}
virtual int replaceObject(App::DocumentObject *oldObj, App::DocumentObject *newObj) {
virtual int replaceObject(App::DocumentObject *oldObj, App::DocumentObject *newObj) override {
App::AutoTransaction committer;
switch (imp->replaceObject(oldObj,newObj)) {
case ViewProviderPythonFeatureImp::Accepted:
@@ -539,6 +539,12 @@ protected:
}
}
//FIXME: ViewProviderPythonFeatureT hides overloaded virtual functions
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Woverloaded-virtual"
#endif
virtual ViewProviderDocumentObject *getLinkedViewProvider(bool recursive=false) const {
auto res = imp->getLinkedViewProvider(recursive);
if(!res)
@@ -546,15 +552,19 @@ protected:
return res;
}
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
public:
virtual void setupContextMenu(QMenu* menu, QObject* recipient, const char* member)
virtual void setupContextMenu(QMenu* menu, QObject* recipient, const char* member) override
{
ViewProviderT::setupContextMenu(menu, recipient, member);
imp->setupContextMenu(menu);
}
protected:
virtual bool doubleClicked(void)
virtual bool doubleClicked(void) override
{
App::AutoTransaction committer;
switch (imp->doubleClicked()) {
@@ -566,7 +576,7 @@ protected:
return ViewProviderT::doubleClicked();
}
}
virtual void setOverrideMode(const std::string &mode)
virtual void setOverrideMode(const std::string &mode) override
{
ViewProviderT::setOverrideMode(mode);
viewerMode = mode;