App: fix memory leaks in Enumeration class and simplify code

This commit is contained in:
wmayer
2022-05-10 18:47:23 +02:00
committed by wwmayer
parent d7313598aa
commit 7db925d991
12 changed files with 329 additions and 340 deletions

View File

@@ -459,7 +459,7 @@ FemPostScalarClipFilter::~FemPostScalarClipFilter() {
DocumentObjectExecReturn* FemPostScalarClipFilter::execute(void) {
std::string val;
if (m_scalarFields.getEnums() && Scalars.getValue() >= 0)
if (m_scalarFields.hasEnums() && Scalars.getValue() >= 0)
val = Scalars.getValueAsString();
std::vector<std::string> array;
@@ -562,7 +562,7 @@ FemPostWarpVectorFilter::~FemPostWarpVectorFilter() {
DocumentObjectExecReturn* FemPostWarpVectorFilter::execute(void) {
std::string val;
if (m_vectorFields.getEnums() && Vector.getValue() >= 0)
if (m_vectorFields.hasEnums() && Vector.getValue() >= 0)
val = Vector.getValueAsString();
std::vector<std::string> array;

View File

@@ -249,7 +249,7 @@ void ViewProviderFemPostObject::updateProperties() {
//coloring
std::string val;
if (Field.getEnums() && Field.getValue() >= 0)
if (Field.hasEnums() && Field.getValue() >= 0)
val = Field.getValueAsString();
std::vector<std::string> colorArrays;
@@ -278,7 +278,7 @@ void ViewProviderFemPostObject::updateProperties() {
Field.purgeTouched();
//Vector mode
if (VectorMode.getEnums() && VectorMode.getValue() >= 0)
if (VectorMode.hasEnums() && VectorMode.getValue() >= 0)
val = VectorMode.getValueAsString();
colorArrays.clear();

View File

@@ -78,17 +78,15 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole* HoleView, QWidget* pare
ui->ThreadType->setCurrentIndex(pcHole->ThreadType.getValue());
ui->ThreadSize->clear();
const char** cursor = pcHole->ThreadSize.getEnums();
while (*cursor) {
ui->ThreadSize->addItem(tr(*cursor));
++cursor;
std::vector<std::string> cursor = pcHole->ThreadSize.getEnumVector();
for (const auto& it : cursor) {
ui->ThreadSize->addItem(tr(it.c_str()));
}
ui->ThreadSize->setCurrentIndex(pcHole->ThreadSize.getValue());
ui->ThreadClass->clear();
cursor = pcHole->ThreadClass.getEnums();
while (*cursor) {
ui->ThreadClass->addItem(tr(*cursor));
++cursor;
cursor = pcHole->ThreadClass.getEnumVector();
for (const auto& it : cursor) {
ui->ThreadClass->addItem(tr(it.c_str()));
}
ui->ThreadClass->setCurrentIndex(pcHole->ThreadClass.getValue());
// Class is only enabled (sensible) if threaded
@@ -109,10 +107,9 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole* HoleView, QWidget* pare
ui->directionRightHand->setEnabled(pcHole->Threaded.getValue());
ui->directionLeftHand->setEnabled(pcHole->Threaded.getValue());
ui->HoleCutType->clear();
cursor = pcHole->HoleCutType.getEnums();
while (*cursor) {
ui->HoleCutType->addItem(tr(*cursor));
++cursor;
cursor = pcHole->HoleCutType.getEnumVector();
for (const auto& it : cursor) {
ui->HoleCutType->addItem(tr(it.c_str()));
}
ui->HoleCutType->setCurrentIndex(pcHole->HoleCutType.getValue());
ui->HoleCutCustomValues->setChecked(pcHole->HoleCutCustomValues.getValue());
@@ -714,10 +711,9 @@ void TaskHoleParameters::changedObject(const App::Document&, const App::Property
ui->ThreadSize->blockSignals(true);
ui->ThreadSize->clear();
const char** cursor = pcHole->ThreadSize.getEnums();
while (*cursor) {
ui->ThreadSize->addItem(QString::fromLatin1(*cursor));
++cursor;
std::vector<std::string> cursor = pcHole->ThreadSize.getEnumVector();
for (const auto& it : cursor) {
ui->ThreadSize->addItem(QString::fromStdString(it));
}
ui->ThreadSize->setCurrentIndex(pcHole->ThreadSize.getValue());
ui->ThreadSize->blockSignals(false);
@@ -725,20 +721,18 @@ void TaskHoleParameters::changedObject(const App::Document&, const App::Property
// Thread type also updates HoleCutType and ThreadClass
ui->HoleCutType->blockSignals(true);
ui->HoleCutType->clear();
cursor = pcHole->HoleCutType.getEnums();
while (*cursor) {
ui->HoleCutType->addItem(QString::fromLatin1(*cursor));
++cursor;
cursor = pcHole->HoleCutType.getEnumVector();
for (const auto& it: cursor) {
ui->HoleCutType->addItem(QString::fromStdString(it));
}
ui->HoleCutType->setCurrentIndex(pcHole->HoleCutType.getValue());
ui->HoleCutType->blockSignals(false);
ui->ThreadClass->blockSignals(true);
ui->ThreadClass->clear();
cursor = pcHole->ThreadClass.getEnums();
while (*cursor) {
ui->ThreadClass->addItem(QString::fromLatin1(*cursor));
++cursor;
cursor = pcHole->ThreadClass.getEnumVector();
for (const auto& it : cursor) {
ui->ThreadClass->addItem(QString::fromStdString(it));
}
ui->ThreadClass->setCurrentIndex(pcHole->ThreadClass.getValue());
ui->ThreadClass->blockSignals(false);