diff options
author | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-04-28 16:18:15 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2016-05-24 06:13:00 +0000 |
commit | a324194b5965b4232b01e38c32741eadc130e8d1 (patch) | |
tree | f0b0cd0f359566717252b9ec3c763166b63e65f8 /src | |
parent | 40074bc985f1fa5c859dc48aed84b48d4c17fff3 (diff) |
QWidgetLineControl::Command - delete default ctor.
While dealing with Coverity's CID 11424 ('missing initializer'), it was
recommended (by Marc, thanks) to get rid of Command's default ctor,
since it's apparently not needed at all (replacing QVector with std::vector also).
Change-Id: Ibe9d2789c67431a9810feb7db4fa1bce0b61921c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 18 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol_p.h | 5 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 9097ad01a8..918b6e8c81 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -697,7 +697,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e if (m_transactions.count()) return false; internalUndo(validateFromState); - m_history.resize(m_undoState); + m_history.erase(m_history.begin() + m_undoState, m_history.end()); if (m_modifiedState > m_undoState) m_modifiedState = -1; m_validInput = true; @@ -776,14 +776,14 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite */ void QWidgetLineControl::addCommand(const Command &cmd) { - if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator) { - m_history.resize(m_undoState + 2); - m_history[m_undoState++] = Command(Separator, m_cursor, 0, m_selstart, m_selend); - } else { - m_history.resize(m_undoState + 1); - } + m_history.erase(m_history.begin() + m_undoState, m_history.end()); + + if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator) + m_history.push_back(Command(Separator, m_cursor, 0, m_selstart, m_selend)); + m_separator = false; - m_history[m_undoState++] = cmd; + m_history.push_back(cmd); + m_undoState = int(m_history.size()); } /*! @@ -1914,7 +1914,7 @@ bool QWidgetLineControl::isRedoAvailable() const // Same as with undo. Disabled for password modes. return !m_readOnly && m_echoMode == QLineEdit::Normal - && m_undoState < m_history.size(); + && m_undoState < int(m_history.size()); } QT_END_NAMESPACE diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 039453f0d5..3d8df9e3ff 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -61,6 +61,8 @@ #include "qplatformdefs.h" +#include <vector> + #ifdef DrawText # undef DrawText #endif @@ -461,7 +463,6 @@ private: // undo/redo handling enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection }; struct Command { - inline Command() {} inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {} uint type : 4; QChar uc; @@ -469,7 +470,7 @@ private: }; int m_modifiedState; int m_undoState; - QVector<Command> m_history; + std::vector<Command> m_history; void addCommand(const Command& cmd); inline void separate() { m_separator = true; } |