diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 90b69881cc..bc66a41bd1 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -457,19 +457,19 @@ void Application::renameDocument(const char *OldName, const char *NewName) Document* Application::newDocument(const char * Name, const char * UserName, DocumentCreateFlags CreateFlags) { auto getNameAndLabel = [this](const char * Name, const char * UserName) -> std::tuple { - bool defaultName = (!Name || Name[0] == '\0'); + bool isDefaultName = Base::Tools::isNullOrEmpty(Name); // get a valid name anyway! - if (defaultName) { + if (isDefaultName) { Name = "Unnamed"; } std::string userName; - if (UserName && UserName[0] != '\0') { + if (!Base::Tools::isNullOrEmpty(UserName)) { userName = UserName; } else { - userName = defaultName ? QObject::tr("Unnamed").toStdString() : Name; + userName = isDefaultName ? QObject::tr("Unnamed").toStdString() : Name; std::vector names; names.reserve(DocMap.size()); @@ -649,8 +649,8 @@ int Application::addPendingDocument(const char *FileName, const char *objName, b return 0; if(allowPartial && _allowPartial) return -1; - assert(FileName && FileName[0]); - assert(objName && objName[0]); + assert(!Base::Tools::isNullOrEmpty(FileName)); + assert(!Base::Tools::isNullOrEmpty(objName)); if(!_docReloadAttempts[FileName].emplace(objName).second) return -1; auto ret = _pendingDocMap.emplace(FileName,std::vector()); diff --git a/src/App/Datums.cpp b/src/App/Datums.cpp index 251f347111..38d214575e 100644 --- a/src/App/Datums.cpp +++ b/src/App/Datums.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "Datums.h" @@ -359,7 +360,7 @@ bool LocalCoordinateSystem::LCSExtension::extensionGetSubObject(DocumentObject*& bool, int depth) const { - if (!subname || subname[0] == '\0') { + if (Base::Tools::isNullOrEmpty(subname)) { return false; } diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 9b583183c0..384e1b899a 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -1457,7 +1457,7 @@ std::vector Document::readObjects(Base::XMLReader& reader) for (int j = 0; j < dcount; ++j) { reader.readElement(FC_ELEMENT_OBJECT_DEP); const char* name = reader.getAttribute(FC_ATTR_DEP_OBJ_NAME); - if (name && name[0]) { + if (!Base::Tools::isNullOrEmpty(name)) { info.deps.insert(name); } } @@ -3570,7 +3570,7 @@ DocumentObject* Document::addObject(const char* sType, } // get Unique name - const bool hasName = pObjectName && pObjectName[0] != '\0'; + const bool hasName = !Base::Tools::isNullOrEmpty(pObjectName); const string ObjectName = getUniqueObjectName(hasName ? pObjectName : type.getName()); d->activeObject = pcObject; @@ -3602,11 +3602,11 @@ DocumentObject* Document::addObject(const char* sType, pcObject->setStatus(ObjectStatus::PartialObject, isPartial); - if (!viewType || viewType[0] == '\0') { + if (Base::Tools::isNullOrEmpty(viewType)) { viewType = pcObject->getViewProviderNameOverride(); } - if (viewType && viewType[0] != '\0') { + if (!Base::Tools::isNullOrEmpty(viewType)) { pcObject->_pcViewProviderName = viewType; } @@ -3746,7 +3746,7 @@ void Document::addObject(DocumentObject* pcObject, const char* pObjectName) // get unique name string ObjectName; - if (pObjectName && pObjectName[0] != '\0') { + if (!Base::Tools::isNullOrEmpty(pObjectName)) { ObjectName = getUniqueObjectName(pObjectName); } else { diff --git a/src/App/License.h b/src/App/License.h index a07e72274d..f6c177361a 100644 --- a/src/App/License.h +++ b/src/App/License.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace App { @@ -65,7 +66,7 @@ constexpr std::array licenseItems {{ int constexpr findLicense(const char* identifier) { - if (!identifier || identifier[0] == '\0') { + if (Base::Tools::isNullOrEmpty(identifier)) { return -1; } for (int i = 0; i < countOfLicenses; i++) { diff --git a/src/App/Link.cpp b/src/App/Link.cpp index 5703c39f00..2762040d42 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -354,11 +354,11 @@ App::DocumentObjectExecReturn* LinkBaseExtension::extensionExecute() auto xlink = Base::freecad_dynamic_cast(getLinkedObjectProperty()); if (xlink) { const char* objname = xlink->getObjectName(); - if (objname && objname[0]) { + if (!Base::Tools::isNullOrEmpty(objname)) { ss << "\nObject: " << objname; } const char* filename = xlink->getFilePath(); - if (filename && filename[0]) { + if (!Base::Tools::isNullOrEmpty(filename)) { ss << "\nFile: " << filename; } } @@ -1756,7 +1756,7 @@ void LinkBaseExtension::parseSubName() const for (std::size_t i = 1; i < subs.size(); ++i) { auto& sub = subs[i]; element = Data::findElementName(sub.c_str()); - if (element && element[0] && boost::starts_with(sub, mySubName)) { + if (!Base::Tools::isNullOrEmpty(element) && boost::starts_with(sub, mySubName)) { mySubElements.emplace_back(element); } } @@ -2265,7 +2265,7 @@ void LinkBaseExtension::onExtendedDocumentRestored() std::set subset(mySubElements.begin(), mySubElements.end()); auto sub = xlink->getSubValues().front(); auto element = Data::findElementName(sub.c_str()); - if (element && element[0]) { + if (!Base::Tools::isNullOrEmpty(element)) { subset.insert(element); sub.resize(element - sub.c_str()); } @@ -2374,7 +2374,7 @@ void LinkBaseExtension::setLink(int index, } int idx = -1; - if (getLinkModeValue() >= LinkModeAutoLink || (subname && subname[0]) + if (getLinkModeValue() >= LinkModeAutoLink || !Base::Tools::isNullOrEmpty(subname) || !subElements.empty() || obj->getDocument() != parent->getDocument() || (getElementListProperty()->find(obj->getNameInDocument(), &idx) && idx != index)) { @@ -2433,7 +2433,7 @@ void LinkBaseExtension::setLink(int index, } if (!xlink) { - if (!subElements.empty() || (subname && subname[0])) { + if (!subElements.empty() || !Base::Tools::isNullOrEmpty(subname)) { LINK_THROW(Base::RuntimeError, "SubName/SubElement link requires PropertyXLink"); } linkProp->setValue(obj); @@ -2448,7 +2448,7 @@ void LinkBaseExtension::setLink(int index, subs.back() += s; } } - else if (subname && subname[0]) { + else if (!Base::Tools::isNullOrEmpty(subname)) { subs.emplace_back(subname); } xlink->setValue(obj, std::move(subs)); diff --git a/src/App/MetadataPyImp.cpp b/src/App/MetadataPyImp.cpp index 1097081c39..c751daa2f3 100644 --- a/src/App/MetadataPyImp.cpp +++ b/src/App/MetadataPyImp.cpp @@ -23,7 +23,9 @@ #include "PreCompiled.h" #include "Metadata.h" + #include +#include // inclusion of the generated files (generated out of MetadataPy.xml) #include "MetadataPy.h" @@ -166,7 +168,7 @@ void MetadataPy::setVersion(Py::String args) if (!PyArg_Parse(args.ptr(), "z", &name)) { throw Py::Exception(); } - if (name && name[0] != '\0') { + if (!Base::Tools::isNullOrEmpty(name)) { getMetadataPtr()->setVersion(App::Meta::Version(std::string(name))); } else { diff --git a/src/App/Property.cpp b/src/App/Property.cpp index 904d91f8ce..4bd598a99a 100644 --- a/src/App/Property.cpp +++ b/src/App/Property.cpp @@ -71,7 +71,7 @@ bool Property::hasName() const bool Property::isValidName(const char* name) { - return name && name[0] != '\0'; + return !Base::Tools::isNullOrEmpty(name); } std::string Property::getFullName() const diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 103e7d5246..1652cb4652 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include "PropertyFile.h" #include "Document.h" @@ -110,7 +111,7 @@ std::string PropertyFileIncluded::getOriginalFileName() const void PropertyFileIncluded::setValue(const char* sFile, const char* sName) { - if (sFile && sFile[0] != '\0') { + if (!Base::Tools::isNullOrEmpty(sFile)) { if (_cValue == sFile) { throw Base::FileSystemError("Not possible to set the same file!"); } diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 4e62852138..8869e199e6 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "PropertyLinks.h" #include "Application.h" @@ -3800,7 +3801,7 @@ void PropertyXLink::hasSetValue() void PropertyXLink::setSubName(const char* subname) { std::vector subs; - if (subname && subname[0]) { + if (!Base::Tools::isNullOrEmpty(subname)) { subs.emplace_back(subname); } aboutToSetValue(); @@ -3830,7 +3831,7 @@ void PropertyXLink::setValue(App::DocumentObject* lValue) void PropertyXLink::setValue(App::DocumentObject* lValue, const char* subname) { std::vector subs; - if (subname && subname[0]) { + if (!Base::Tools::isNullOrEmpty(subname)) { subs.emplace_back(subname); } setValue(lValue, std::move(subs)); @@ -4147,7 +4148,7 @@ void PropertyXLink::Save(Base::Writer& writer) const else { auto pDoc = owner->getDocument(); const char* docPath = pDoc->getFileName(); - if (docPath && docPath[0]) { + if (!Base::Tools::isNullOrEmpty(docPath)) { if (!filePath.empty()) { _path = DocInfo::getDocPath(filePath.c_str(), pDoc, false); } diff --git a/src/Base/ConsoleObserver.cpp b/src/Base/ConsoleObserver.cpp index 1fd0ae5ead..8b862991ba 100644 --- a/src/Base/ConsoleObserver.cpp +++ b/src/Base/ConsoleObserver.cpp @@ -35,6 +35,7 @@ #include "ConsoleObserver.h" #include "Interpreter.h" +#include "Tools.h" using namespace Base; @@ -343,7 +344,7 @@ std::stringstream& LogLevel::prefix(std::stringstream& str, const char* src, int #endif } } - if (print_src && src && src[0]) { + if (print_src && !Base::Tools::isNullOrEmpty(src)) { #ifdef FC_OS_WIN32 const char* _f = std::strrchr(src, '\\'); #else diff --git a/src/Base/FileInfo.cpp b/src/Base/FileInfo.cpp index 082a20f6b8..1eed561992 100644 --- a/src/Base/FileInfo.cpp +++ b/src/Base/FileInfo.cpp @@ -45,6 +45,7 @@ #include "Exception.h" #include "Stream.h" #include "TimeInfo.h" +#include "Tools.h" using namespace Base; @@ -119,7 +120,7 @@ const std::string& FileInfo::getTempPath() delete[] dest; #else const char* tmp = getenv("TMPDIR"); - if (tmp && tmp[0] != '\0') { + if (!Base::Tools::isNullOrEmpty(tmp)) { tempPath = tmp; FileInfo fi(tempPath); if (tempPath.empty() || !fi.isDir()) { // still empty or non-existent diff --git a/src/Base/ParameterPy.cpp b/src/Base/ParameterPy.cpp index 58b88f0bf5..07483ef92e 100644 --- a/src/Base/ParameterPy.cpp +++ b/src/Base/ParameterPy.cpp @@ -42,6 +42,8 @@ #include "Exception.h" #include "Interpreter.h" +#include + namespace Base { @@ -73,7 +75,7 @@ public: Py::Tuple args(2); args.setItem(0, Py::asObject(GetPyObject(hGrp))); // A Reason of null indicates to clear the parameter group - if (Reason && Reason[0] != '\0') { + if (!Base::Tools::isNullOrEmpty(Reason)) { args.setItem(1, Py::String(Reason)); } method.apply(args); diff --git a/src/Base/Tools.h b/src/Base/Tools.h index 43685506e5..6c0e0657ec 100644 --- a/src/Base/Tools.h +++ b/src/Base/Tools.h @@ -301,6 +301,11 @@ struct BaseExport Tools */ static std::string quoted(const std::string&); + static constexpr bool isNullOrEmpty(const char* str) + { + return !str || str[0] == '\0'; + } + /** * @brief joinList * Join the vector of strings \a vec using the separator \a sep diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 5fb02b32bc..4e1ddda1eb 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -1422,7 +1422,7 @@ Action * PythonCommand::createAction() const char* PythonCommand::getWhatsThis() const { const char* whatsthis = getResource("WhatsThis"); - if (!whatsthis || whatsthis[0] == '\0') + if (Base::Tools::isNullOrEmpty(whatsthis)) whatsthis = this->getName(); return whatsthis; } @@ -1445,7 +1445,7 @@ const char* PythonCommand::getStatusTip() const const char* PythonCommand::getPixmap() const { const char* ret = getResource("Pixmap"); - return (ret && ret[0] != '\0') ? ret : nullptr; + return !Base::Tools::isNullOrEmpty(ret) ? ret : nullptr; } const char* PythonCommand::getAccel() const @@ -1740,7 +1740,7 @@ const char* PythonGroupCommand::getResource(const char* sName) const const char* PythonGroupCommand::getWhatsThis() const { const char* whatsthis = getResource("WhatsThis"); - if (!whatsthis || whatsthis[0] == '\0') + if (Base::Tools::isNullOrEmpty(whatsthis)) whatsthis = this->getName(); return whatsthis; } @@ -1763,7 +1763,7 @@ const char* PythonGroupCommand::getStatusTip() const const char* PythonGroupCommand::getPixmap() const { const char* ret = getResource("Pixmap"); - return (ret && ret[0] != '\0') ? ret : nullptr; + return !Base::Tools::isNullOrEmpty(ret) ? ret : nullptr; } const char* PythonGroupCommand::getAccel() const @@ -1988,7 +1988,7 @@ void CommandManager::updateCommands(const char* sContext, int mode) const Command* Gui::CommandManager::checkAcceleratorForConflicts(const char* accel, const Command* ignore) const { - if (!accel || accel[0] == '\0') + if (Base::Tools::isNullOrEmpty(accel)) return nullptr; QString newCombo = QString::fromLatin1(accel); @@ -2004,7 +2004,7 @@ const Command* Gui::CommandManager::checkAcceleratorForConflicts(const char* acc if (cmd == ignore) continue; auto existingAccel = cmd->getAccel(); - if (!existingAccel || existingAccel[0] == '\0') + if (Base::Tools::isNullOrEmpty(existingAccel)) continue; // Three possible conflict scenarios: diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp index eddb113e8a..76eafdbd63 100644 --- a/src/Gui/CommandLink.cpp +++ b/src/Gui/CommandLink.cpp @@ -302,7 +302,7 @@ void StdCmdLinkMakeRelative::activated(int) { auto element = Data::findElementName(sel.SubName); auto &info = linkInfo[key]; info.first = sel.pResolvedObject; - if(element && element[0]) + if(!Base::Tools::isNullOrEmpty(element)) info.second.emplace_back(element); } diff --git a/src/Gui/Dialogs/DlgPropertyLink.cpp b/src/Gui/Dialogs/DlgPropertyLink.cpp index 0417c688da..7de89699f2 100644 --- a/src/Gui/Dialogs/DlgPropertyLink.cpp +++ b/src/Gui/Dialogs/DlgPropertyLink.cpp @@ -640,7 +640,7 @@ DlgPropertyLink::findItem(App::DocumentObject* obj, const char* subname, bool* p } std::vector sobjs; - if (subname && subname[0]) { + if (!Base::Tools::isNullOrEmpty(subname)) { if (!allowSubObject) { obj = obj->getSubObject(subname); if (!obj) { diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 432214d4de..4a16841c4c 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1701,7 +1701,7 @@ void Document::RestoreDocFile(Base::Reader &reader) localreader->readElement("Camera"); const char* ppReturn = localreader->getAttribute("settings"); cameraSettings.clear(); - if(ppReturn && ppReturn[0]) { + if(!Base::Tools::isNullOrEmpty(ppReturn)) { saveCameraSettings(ppReturn); try { const char** pReturnIgnore=nullptr; diff --git a/src/Gui/Selection/Selection.cpp b/src/Gui/Selection/Selection.cpp index b8fdab737e..0c9b8c65a8 100644 --- a/src/Gui/Selection/Selection.cpp +++ b/src/Gui/Selection/Selection.cpp @@ -838,7 +838,7 @@ void SelectionSingleton::rmvSelectionGate() App::Document* SelectionSingleton::getDocument(const char* pDocName) const { - if (pDocName && pDocName[0]) + if (!Base::Tools::isNullOrEmpty(pDocName)) return App::GetApplication().getDocument(pDocName); else return App::GetApplication().getActiveDocument(); diff --git a/src/Gui/Selection/SelectionFilter.cpp b/src/Gui/Selection/SelectionFilter.cpp index 991521fb1e..b189ba02cd 100644 --- a/src/Gui/Selection/SelectionFilter.cpp +++ b/src/Gui/Selection/SelectionFilter.cpp @@ -31,7 +31,7 @@ #include #include #include - +#include #include "Selection.h" #include "SelectionFilter.h" #include "SelectionFilterPy.h" @@ -145,7 +145,7 @@ SelectionFilter::SelectionFilter(const std::string& filter) void SelectionFilter::setFilter(const char* filter) { - if (!filter || filter[0] == 0) { + if (Base::Tools::isNullOrEmpty(filter)) { Ast.reset(); Filter.clear(); } diff --git a/src/Gui/ShortcutManager.cpp b/src/Gui/ShortcutManager.cpp index 16830c514e..c7103f7c7a 100644 --- a/src/Gui/ShortcutManager.cpp +++ b/src/Gui/ShortcutManager.cpp @@ -122,7 +122,7 @@ void ShortcutManager::OnChange(Base::Subject &src, const char *reas void ShortcutManager::reset(const char *cmd) { - if (cmd && cmd[0]) { + if (!Base::Tools::isNullOrEmpty(cmd)) { QKeySequence oldShortcut = getShortcut(cmd); hShortcuts->RemoveASCII(cmd); if (oldShortcut != getShortcut(cmd)) @@ -172,7 +172,7 @@ QString ShortcutManager::getShortcut(const char *cmdName, const char *accel) void ShortcutManager::setShortcut(const char *cmdName, const char *accel) { - if (cmdName && cmdName[0]) { + if (!Base::Tools::isNullOrEmpty(cmdName)) { setTopPriority(cmdName); if (!accel) accel = ""; diff --git a/src/Gui/ViewProvider.cpp b/src/Gui/ViewProvider.cpp index 33abc679ae..2acaebea60 100644 --- a/src/Gui/ViewProvider.cpp +++ b/src/Gui/ViewProvider.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include "Inventor/SoMouseWheelEvent.h" #include "Inventor/SoFCTransform.h" @@ -1032,7 +1033,7 @@ Base::BoundBox3d ViewProvider::getBoundingBox(const char *subname, bool transfor SoTempPath path(20); path.ref(); - if(subname && subname[0]) { + if(!Base::Tools::isNullOrEmpty(subname)) { SoDetail *det=nullptr; if(!getDetailPath(subname,&path,true,det)) { if(mode < 0) diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 63857efd54..14b15f44ac 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -2342,7 +2342,7 @@ bool ViewProviderLink::getDetailPath( return false; } std::string _subname; - if(subname && subname[0]) { + if(!Base::Tools::isNullOrEmpty(subname)) { if (auto linked = ext->getLinkedObjectValue()) { if (const char *dot = strchr(subname,'.')) { if(subname[0]=='$') { diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 8d95ef7d84..c619e6e891 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -4705,7 +4705,7 @@ QVariant PropertyLinkItem::data(int column, int role) const if (role == Qt::ToolTipRole) { if (auto xlink = dynamic_cast(propertyItems[0])) { const char* filePath = xlink->getFilePath(); - if (filePath && filePath[0]) { + if (!Base::Tools::isNullOrEmpty(filePath)) { return QVariant::fromValue(QString::fromUtf8(filePath)); } } diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index d20c8e0dfa..bb5e565f8d 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -26,6 +26,8 @@ #include #endif +#include + #include "PropertyItem.h" #include "PropertyModel.h" #include "PropertyView.h" @@ -271,7 +273,7 @@ static PropertyItem* createPropertyItem(App::Property* prop) PropertyModel::GroupInfo& PropertyModel::getGroupInfo(App::Property* prop) { const char* group = prop->getGroup(); - bool isEmpty = (!group || group[0] == '\0'); + bool isEmpty = Base::Tools::isNullOrEmpty(group); QString groupName = QString::fromLatin1(isEmpty ? QT_TRANSLATE_NOOP("App::Property", "Base") : group); diff --git a/src/Mod/Fem/Gui/FemSelectionGate.cpp b/src/Mod/Fem/Gui/FemSelectionGate.cpp index 06c5730ca9..afe4d48c9d 100644 --- a/src/Mod/Fem/Gui/FemSelectionGate.cpp +++ b/src/Mod/Fem/Gui/FemSelectionGate.cpp @@ -22,6 +22,8 @@ #include "PreCompiled.h" +#include + #include "FemSelectionGate.h" @@ -32,7 +34,7 @@ bool FemSelectionGate::allow(App::Document* /*pDoc*/, App::DocumentObject* /*pObj*/, const char* sSubName) { - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index c14aa38d89..7058f66d1e 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -2368,12 +2368,12 @@ private: std::string subname(sub); if (!subname.empty() && subname[subname.size()-1]!='.') subname += '.'; - if (mapped && mapped[0]) { + if (!Base::Tools::isNullOrEmpty(mapped)) { if (!Data::isMappedElement(mapped)) subname += Data::ELEMENT_MAP_PREFIX; subname += mapped; } - if (element && element[0]) { + if (!Base::Tools::isNullOrEmpty(element)) { if (!subname.empty() && subname[subname.size()-1]!='.') subname += '.'; subname += element; diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index b20571b5af..d89d58b108 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -2555,7 +2555,7 @@ PyObject* TopoShapePy::getChildShapes(PyObject* args) return Py::new_reference_to( getElements(*getTopoShapePtr(), TopoShape::shapeType(type), - avoid && avoid[0] ? TopoShape::shapeType(avoid) : TopAbs_SHAPE)); + !Base::Tools::isNullOrEmpty(avoid) ? TopoShape::shapeType(avoid) : TopAbs_SHAPE)); } PY_CATCH_OCC; } diff --git a/src/Mod/Part/Gui/BoxSelection.cpp b/src/Mod/Part/Gui/BoxSelection.cpp index e13f29be07..f2aa123f02 100644 --- a/src/Mod/Part/Gui/BoxSelection.cpp +++ b/src/Mod/Part/Gui/BoxSelection.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -60,7 +61,7 @@ public: ~FaceSelectionGate() override = default; bool allow(App::Document*, App::DocumentObject*, const char*sSubName) override { - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return false; std::string element(sSubName); return element.substr(0,4) == "Face"; diff --git a/src/Mod/Part/Gui/DlgExtrusion.cpp b/src/Mod/Part/Gui/DlgExtrusion.cpp index 4748d1e205..76cbea4787 100644 --- a/src/Mod/Part/Gui/DlgExtrusion.cpp +++ b/src/Mod/Part/Gui/DlgExtrusion.cpp @@ -39,6 +39,8 @@ #include #include #include +#include + #include #include #include @@ -51,7 +53,8 @@ #include "DlgExtrusion.h" -FC_LOG_LEVEL_INIT("Part",true,true) + +FC_LOG_LEVEL_INIT("Part", true, true) using namespace PartGui; @@ -69,7 +72,7 @@ public: { this->canSelect = false; - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return false; std::string element(sSubName); if (element.substr(0,4) != "Edge") diff --git a/src/Mod/Part/Gui/DlgFilletEdges.cpp b/src/Mod/Part/Gui/DlgFilletEdges.cpp index 0dfeeb43aa..c8eda7674b 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.cpp +++ b/src/Mod/Part/Gui/DlgFilletEdges.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -186,7 +187,7 @@ namespace PartGui { { if (pObj != this->object) return false; - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return false; std::string element(sSubName); if (allowEdge) diff --git a/src/Mod/Part/Gui/DlgRevolution.cpp b/src/Mod/Part/Gui/DlgRevolution.cpp index 2e7b834577..950552184b 100644 --- a/src/Mod/Part/Gui/DlgRevolution.cpp +++ b/src/Mod/Part/Gui/DlgRevolution.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -67,7 +68,7 @@ public: { this->canSelect = false; - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return false; std::string element(sSubName); if (element.substr(0,4) != "Edge") diff --git a/src/Mod/Part/Gui/TaskFaceAppearances.cpp b/src/Mod/Part/Gui/TaskFaceAppearances.cpp index 0341d443fd..a1f2b5d6f3 100644 --- a/src/Mod/Part/Gui/TaskFaceAppearances.cpp +++ b/src/Mod/Part/Gui/TaskFaceAppearances.cpp @@ -44,6 +44,7 @@ #endif #include +#include #include #include #include @@ -79,7 +80,7 @@ namespace PartGui { { if (pObj != this->object) return false; - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return false; std::string element(sSubName); return element.substr(0, 4) == "Face"; diff --git a/src/Mod/Part/Gui/TaskShapeBuilder.cpp b/src/Mod/Part/Gui/TaskShapeBuilder.cpp index 0a725c9850..8dfa5c65c1 100644 --- a/src/Mod/Part/Gui/TaskShapeBuilder.cpp +++ b/src/Mod/Part/Gui/TaskShapeBuilder.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -69,7 +70,7 @@ namespace PartGui { { if (!obj || !obj->isDerivedFrom()) return false; - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return (mode == ALL); std::string element(sSubName); switch (mode) { diff --git a/src/Mod/Part/Gui/TaskSweep.cpp b/src/Mod/Part/Gui/TaskSweep.cpp index 8e12ff9b5a..8371d3bb49 100644 --- a/src/Mod/Part/Gui/TaskSweep.cpp +++ b/src/Mod/Part/Gui/TaskSweep.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -76,7 +77,7 @@ public: } bool allow(App::Document* /*pDoc*/, App::DocumentObject*pObj, const char*sSubName) override { - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { // If selecting again the same edge the passed sub-element is empty. If the whole // shape is an edge or wire we can use it completely. Part::TopoShape topoShape = Part::Feature::getTopoShape(pObj); diff --git a/src/Mod/Part/Gui/TaskThickness.cpp b/src/Mod/Part/Gui/TaskThickness.cpp index 85ad7aff51..09ed63c457 100644 --- a/src/Mod/Part/Gui/TaskThickness.cpp +++ b/src/Mod/Part/Gui/TaskThickness.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -65,7 +66,7 @@ public: { if (pObj != this->object) return false; - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return false; std::string element(sSubName); return element.substr(0,4) == "Face"; diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index f9ab52a741..3290db6e5b 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -86,7 +87,7 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c } #endif // Handle selection of geometry elements - if (!sSubName || sSubName[0] == '\0') + if (Base::Tools::isNullOrEmpty(sSubName)) return type.testFlag(AllowSelection::WHOLE); // resolve links if needed diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 7dc489c4d3..0706d22c2e 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -924,7 +924,7 @@ public: if (pObj != this->object) { return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } std::string element(sSubName); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h index a6fe1913c6..f6561f017d 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h @@ -57,7 +57,7 @@ public: if (pObj != this->object) { return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } if (disabled) { diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h index efa9d5a449..6623688796 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h @@ -97,7 +97,7 @@ public: // return false; //} - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } std::string element(sSubName); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h index 9eaeb007e9..f1da6a0885 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h @@ -57,7 +57,7 @@ public: if (pObj != this->object) { return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } std::string element(sSubName); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h index 8ac7ff7378..3c3ec5e00b 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h @@ -57,7 +57,7 @@ public: if (pObj != this->object) { return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } std::string element(sSubName); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h index d195475139..e226c1f5aa 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h @@ -59,7 +59,7 @@ public: if (pObj != this->object) { return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } std::string element(sSubName); diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index edaadb440c..8e1dfbb34e 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -35,6 +35,7 @@ #endif #include +#include #include #include #include @@ -47,6 +48,7 @@ #include "TaskFilling.h" #include "TaskFillingEdge.h" #include "TaskFillingVertex.h" + #include "ui_TaskFilling.h" @@ -216,7 +218,7 @@ public: return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.cpp b/src/Mod/Surface/Gui/TaskFillingEdge.cpp index b2501c73e3..6030eaca47 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.cpp +++ b/src/Mod/Surface/Gui/TaskFillingEdge.cpp @@ -35,6 +35,7 @@ #endif #include +#include #include #include #include @@ -44,6 +45,7 @@ #include "TaskFilling.h" #include "TaskFillingEdge.h" + #include "ui_TaskFillingEdge.h" @@ -77,7 +79,7 @@ public: return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index df1afc97fb..c684cc7dd4 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -27,6 +27,7 @@ #endif #include +#include #include #include #include @@ -36,6 +37,7 @@ #include "TaskFilling.h" #include "TaskFillingVertex.h" + #include "ui_TaskFillingVertex.h" @@ -69,7 +71,7 @@ public: return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp index 9a1b1883cb..c862e533fd 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #include #include "TaskGeomFillSurface.h" + #include "ui_TaskGeomFillSurface.h" @@ -172,7 +174,7 @@ bool GeomFillSurface::EdgeSelection::allow(App::Document*, return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; } diff --git a/src/Mod/Surface/Gui/TaskSections.cpp b/src/Mod/Surface/Gui/TaskSections.cpp index d4b9d94057..519b93690b 100644 --- a/src/Mod/Surface/Gui/TaskSections.cpp +++ b/src/Mod/Surface/Gui/TaskSections.cpp @@ -32,6 +32,7 @@ #endif #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include "TaskSections.h" + #include "ui_TaskSections.h" @@ -216,7 +218,7 @@ public: return false; } - if (!sSubName || sSubName[0] == '\0') { + if (Base::Tools::isNullOrEmpty(sSubName)) { return false; }