QWidgetLineControl: replace raw memory handling with std::unique_ptr
Change-Id: I131175a9f7147783c4f4c0a1c4929e28677c159a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
b40c8e3068
commit
0daed8dee8
|
|
@ -963,8 +963,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
|
|||
int delimiter = maskFields.indexOf(QLatin1Char(';'));
|
||||
if (maskFields.isEmpty() || delimiter == 0) {
|
||||
if (m_maskData) {
|
||||
delete [] m_maskData;
|
||||
m_maskData = nullptr;
|
||||
m_maskData.reset();
|
||||
m_maxLength = 32767;
|
||||
internalSetText(QString(), -1, false);
|
||||
}
|
||||
|
|
@ -1002,8 +1001,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
|
|||
m_maxLength++;
|
||||
}
|
||||
|
||||
delete [] m_maskData;
|
||||
m_maskData = new MaskInputData[m_maxLength];
|
||||
m_maskData = std::make_unique<MaskInputData[]>(m_maxLength);
|
||||
|
||||
MaskInputData::Casemode m = MaskInputData::NoCaseMode;
|
||||
bool s;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
#include "qplatformdefs.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#ifdef DrawText
|
||||
# undef DrawText
|
||||
|
|
@ -111,8 +112,6 @@ public:
|
|||
// to zero it out
|
||||
if (m_echoMode != QLineEdit::Normal)
|
||||
m_text.fill(u'\0');
|
||||
|
||||
delete [] m_maskData;
|
||||
}
|
||||
|
||||
void setAccessibleObject(QObject *object)
|
||||
|
|
@ -465,7 +464,7 @@ private:
|
|||
};
|
||||
QString m_inputMask;
|
||||
QChar m_blank;
|
||||
MaskInputData *m_maskData;
|
||||
std::unique_ptr<MaskInputData[]> m_maskData;
|
||||
|
||||
// undo/redo handling
|
||||
enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
|
||||
|
|
|
|||
Loading…
Reference in New Issue