Merge pull request #19739 from kadet1090/is-null-or-empty

Base: Add isNullOrEmpty string helper
This commit is contained in:
Chris Hennes
2025-02-21 13:49:10 -06:00
committed by GitHub
47 changed files with 113 additions and 72 deletions
+6 -6
View File
@@ -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<std::string, std::string> {
bool defaultName = (!Name || Name[0] == '\0');
bool isDefaultName = 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<std::string> 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<std::string>());
+2 -1
View File
@@ -29,6 +29,7 @@
#include <App/Document.h>
#include <Base/Exception.h>
#include <Base/Placement.h>
#include <Base/Tools.h>
#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;
}
+5 -5
View File
@@ -1457,7 +1457,7 @@ std::vector<App::DocumentObject*> 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 {
+2 -1
View File
@@ -26,6 +26,7 @@
#include <array>
#include <cstring>
#include <string>
#include <Base/Tools.h>
namespace App
{
@@ -65,7 +66,7 @@ constexpr std::array<TLicenseArr, countOfLicenses> 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++) {
+7 -7
View File
@@ -354,11 +354,11 @@ App::DocumentObjectExecReturn* LinkBaseExtension::extensionExecute()
auto xlink = Base::freecad_dynamic_cast<PropertyXLink>(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<std::string> 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));
+3 -1
View File
@@ -23,7 +23,9 @@
#include "PreCompiled.h"
#include "Metadata.h"
#include <Base/FileInfo.h>
#include <Base/Tools.h>
// 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 {
+1 -1
View File
@@ -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
+2 -1
View File
@@ -29,6 +29,7 @@
#include <Base/Stream.h>
#include <Base/Writer.h>
#include <Base/Uuid.h>
#include <Base/Tools.h>
#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!");
}
+4 -3
View File
@@ -31,6 +31,7 @@
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Base/Tools.h>
#include "PropertyLinks.h"
#include "Application.h"
@@ -3800,7 +3801,7 @@ void PropertyXLink::hasSetValue()
void PropertyXLink::setSubName(const char* subname)
{
std::vector<std::string> 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<std::string> 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);
}
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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
+3 -1
View File
@@ -42,6 +42,8 @@
#include "Exception.h"
#include "Interpreter.h"
#include <Tools.h>
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);
+5
View File
@@ -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
+6 -6
View File
@@ -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:
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -640,7 +640,7 @@ DlgPropertyLink::findItem(App::DocumentObject* obj, const char* subname, bool* p
}
std::vector<App::DocumentObject*> sobjs;
if (subname && subname[0]) {
if (!Base::Tools::isNullOrEmpty(subname)) {
if (!allowSubObject) {
obj = obj->getSubObject(subname);
if (!obj) {
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -31,7 +31,7 @@
#include <App/DocumentObjectPy.h>
#include <App/DocumentObject.h>
#include <Base/Interpreter.h>
#include <Base/Tools.h>
#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();
}
+2 -2
View File
@@ -122,7 +122,7 @@ void ShortcutManager::OnChange(Base::Subject<const char*> &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 = "";
+2 -1
View File
@@ -40,6 +40,7 @@
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Matrix.h>
#include <Base/Tools.h>
#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)
+1 -1
View File
@@ -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]=='$') {
+1 -1
View File
@@ -4705,7 +4705,7 @@ QVariant PropertyLinkItem::data(int column, int role) const
if (role == Qt::ToolTipRole) {
if (auto xlink = dynamic_cast<const App::PropertyXLink*>(propertyItems[0])) {
const char* filePath = xlink->getFilePath();
if (filePath && filePath[0]) {
if (!Base::Tools::isNullOrEmpty(filePath)) {
return QVariant::fromValue(QString::fromUtf8(filePath));
}
}
+3 -1
View File
@@ -26,6 +26,8 @@
#include <boost/algorithm/string/predicate.hpp>
#endif
#include <Base/Tools.h>
#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);
+3 -1
View File
@@ -22,6 +22,8 @@
#include "PreCompiled.h"
#include <Base/Tools.h>
#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;
}
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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;
}
+2 -1
View File
@@ -36,6 +36,7 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection/Selection.h>
@@ -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";
+5 -2
View File
@@ -39,6 +39,8 @@
#include <App/Link.h>
#include <App/Part.h>
#include <Base/UnitsApi.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -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")
+2 -1
View File
@@ -50,6 +50,7 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Base/UnitsApi.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -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)
+2 -1
View File
@@ -38,6 +38,7 @@
#include <App/DocumentObject.h>
#include <App/Link.h>
#include <App/Part.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -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")
+2 -1
View File
@@ -44,6 +44,7 @@
#endif
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/Control.h>
#include <Gui/Dialogs/DlgMaterialPropertiesImp.h>
@@ -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";
+2 -1
View File
@@ -35,6 +35,7 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -69,7 +70,7 @@ namespace PartGui {
{
if (!obj || !obj->isDerivedFrom<Part::Feature>())
return false;
if (!sSubName || sSubName[0] == '\0')
if (Base::Tools::isNullOrEmpty(sSubName))
return (mode == ALL);
std::string element(sSubName);
switch (mode) {
+2 -1
View File
@@ -41,6 +41,7 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/Link.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -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);
+2 -1
View File
@@ -28,6 +28,7 @@
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -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";
@@ -35,6 +35,7 @@
#include <App/Origin.h>
#include <App/Datums.h>
#include <App/Part.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
@@ -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
+1 -1
View File
@@ -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);
@@ -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) {
@@ -97,7 +97,7 @@ public:
// return false;
//}
if (!sSubName || sSubName[0] == '\0') {
if (Base::Tools::isNullOrEmpty(sSubName)) {
return false;
}
std::string element(sSubName);
@@ -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);
@@ -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);
@@ -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);
+3 -1
View File
@@ -35,6 +35,7 @@
#endif
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -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;
}
+3 -1
View File
@@ -35,6 +35,7 @@
#endif
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
@@ -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;
}
+3 -1
View File
@@ -27,6 +27,7 @@
#endif
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
@@ -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;
}
+3 -1
View File
@@ -33,6 +33,7 @@
#include <App/Document.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -43,6 +44,7 @@
#include <Mod/Part/Gui/ViewProvider.h>
#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;
}
+3 -1
View File
@@ -32,6 +32,7 @@
#endif
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
@@ -41,6 +42,7 @@
#include <Mod/Part/Gui/ViewProvider.h>
#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;
}