* Prevent naming properties with reserved words (Fix #16846) * Prevent using reserved constant names for properties or aliases * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * App: Add unit test for isTokenAConstant --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/ExpressionParser.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
#include "DlgAddProperty.h"
|
||||
@@ -111,6 +112,13 @@ void DlgAddProperty::accept()
|
||||
if(ui->chkAppend->isChecked())
|
||||
name = group + "_" + name;
|
||||
|
||||
if (App::ExpressionParser::isTokenAUnit(name) || App::ExpressionParser::isTokenAConstant(name)) {
|
||||
QMessageBox::critical(getMainWindow(),
|
||||
QObject::tr("Invalid name"),
|
||||
QObject::tr("The property name is a reserved word."));
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto c : containers) {
|
||||
auto prop = c->getPropertyByName(name.c_str());
|
||||
if(prop && prop->getContainer() == c) {
|
||||
|
||||
Reference in New Issue
Block a user