From b61a2d178d7c8ea5f35999be42edf76f4e1eb982 Mon Sep 17 00:00:00 2001 From: sunwen Date: Fri, 21 Jun 2024 15:14:54 +0800 Subject: [PATCH] fix: Fix setValidator memory leak. --- src/dialogs/AccountFormDialog.cpp | 2 +- src/dialogs/EditPatientDialog.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dialogs/AccountFormDialog.cpp b/src/dialogs/AccountFormDialog.cpp index c0f418c..a792d6d 100644 --- a/src/dialogs/AccountFormDialog.cpp +++ b/src/dialogs/AccountFormDialog.cpp @@ -49,7 +49,7 @@ AccountFormDialog::AccountFormDialog(QWidget* parent, AccountEditMode mode, Qt:: &AccountFormDialog::changeSelfPassword : &AccountFormDialog::resetUserPassword); } - mLeUserName->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$"))); + mLeUserName->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$"), mLeUserName)); connect(mLeComment, &QLineEdit::textChanged, [=](const QString& text) { mCommentChanged = true; }); diff --git a/src/dialogs/EditPatientDialog.cpp b/src/dialogs/EditPatientDialog.cpp index 1e4b1c0..e08fbd7 100644 --- a/src/dialogs/EditPatientDialog.cpp +++ b/src/dialogs/EditPatientDialog.cpp @@ -48,7 +48,7 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo QLabel* lbl_id = new QLabel(this); lbl_id->setText(tr("ID ") + QString("*")); le_id = new ULineEdit(this); - le_id->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"))); + le_id->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), le_id)); layout->addWidget(lbl_id); layout->addWidget(le_id); QLabel* lbl_endline1 = new QLabel(this); @@ -59,7 +59,7 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo QLabel* lbl_AccessionNumber = new QLabel(this); lbl_AccessionNumber->setText(tr("Accession Number")); mAccessionNumber = new ULineEdit(this); - mAccessionNumber->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"))); + mAccessionNumber->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mAccessionNumber)); layout->addWidget(lbl_AccessionNumber); layout->addWidget(mAccessionNumber); @@ -71,7 +71,7 @@ EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFo QLabel* lbl_name = new QLabel(this); lbl_name->setText(tr("Name") + QString("*")); le_name = new ULineEdit(this); - le_name->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$"))); + le_name->setValidator(new QRegExpValidator(QRegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$"), le_name)); layout->addWidget(lbl_name); layout->addWidget(le_name); QLabel* lbl_endline2 = new QLabel(this); @@ -180,13 +180,13 @@ bool EditPatientDialog::updateReferenceData() PatientInformation* inf = getPatientInformation(); if (le_id->text().isEmpty()) { - showErrorMessage("ID can't be empty!"); + showErrorMessage(tr("ID can't be empty!")); return false; } inf->ID = le_id->text().trimmed(); if (le_name->text().isEmpty()) { - showErrorMessage("Patient Name can't be empty!"); + showErrorMessage(tr("Patient Name can't be empty!")); return false; } inf->AccessionNumber = mAccessionNumber->text().trimmed(); @@ -198,7 +198,7 @@ bool EditPatientDialog::updateReferenceData() int ref_rowid = queryValue(model, 1, inf->ID, 2, inf->AccessionNumber); if (ref_rowid >= 0) { - showErrorMessage("The ID and Accession number is already existed!"); + showErrorMessage(tr("The ID and Accession number is already existed!")); return false; } inf->PatientUID = QUuid::createUuid().toString();