From 5810c72bc2643733b5f0afd45cc77ce14e3c8d14 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sat, 2 Dec 2006 21:39:09 +0100 Subject: [PATCH] Introduce an accessor to set the value text of an expression item. It will be needed for the QListView rewrite anyway. --- kdbg/dbgdriver.cpp | 2 +- kdbg/debugger.cpp | 6 +++--- kdbg/exprwnd.cpp | 24 ++++++++++++------------ kdbg/exprwnd.h | 6 +++++- kdbg/gdbdriver.cpp | 2 +- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/kdbg/dbgdriver.cpp b/kdbg/dbgdriver.cpp index af061bd..a3652c3 100644 --- a/kdbg/dbgdriver.cpp +++ b/kdbg/dbgdriver.cpp @@ -479,7 +479,7 @@ void DebuggerDriver::dequeueCmdByVar(VarTree* var) QString DebuggerDriver::editableValue(VarTree* value) { // by default, let the user edit what is visible - return value->m_value; + return value->value(); } diff --git a/kdbg/debugger.cpp b/kdbg/debugger.cpp index b09ea99..233cf01 100644 --- a/kdbg/debugger.cpp +++ b/kdbg/debugger.cpp @@ -1424,7 +1424,7 @@ bool KDebugger::handlePrintDeref(CmdQueueItem* cmd, const char* output) ExprValue* dummyParent = new ExprValue(variable->m_name, VarTree::NKplain); dummyParent->m_varKind = VarTree::VKdummy; // the name of the parsed variable is the address of the pointer - QString addr = "*" + cmd->m_expr->m_value; + QString addr = "*" + cmd->m_expr->value(); variable->m_name = addr; variable->m_nameKind = VarTree::NKaddress; @@ -2098,9 +2098,9 @@ void KDebugger::slotValuePopup(const QString& expr) // construct the tip QString tip = v->getText() + " = "; - if (!v->m_value.isEmpty()) + if (!v->value().isEmpty()) { - tip += v->m_value; + tip += v->value(); } else { diff --git a/kdbg/exprwnd.cpp b/kdbg/exprwnd.cpp index 7637c87..080f0d3 100644 --- a/kdbg/exprwnd.cpp +++ b/kdbg/exprwnd.cpp @@ -20,11 +20,11 @@ VarTree::VarTree(ExprValue* v) : KTreeViewItem(v->m_name), m_varKind(v->m_varKind), m_nameKind(v->m_nameKind), - m_value(v->m_value), m_valueChanged(false), m_type(0), m_exprIndex(0), - m_exprIndexUseGuard(false) + m_exprIndexUseGuard(false), + m_value(v->m_value) { setDelayedExpanding(m_varKind == VKpointer); setExpanded(v->m_initiallyExpanded); @@ -57,14 +57,14 @@ void VarTree::paintValue(QPainter* p) p->setPen(red); } // p->setBackgroundColor(cg.base()); - p->drawText(textX, textY, m_value, m_value.length()); + p->drawText(textX, textY, value(), value().length()); p->restore(); } int VarTree::valueWidth() { assert(owner != 0); - return owner->fontMetrics().width(m_value) + 4; + return owner->fontMetrics().width(value()) + 4; } QString VarTree::computeExpr() const @@ -145,8 +145,8 @@ bool VarTree::updateValue(const QString& newValue) // check whether the value changed bool prevValueChanged = m_valueChanged; m_valueChanged = false; - if (m_value != newValue) { - m_value = newValue; + if (value() != newValue) { + setValue(newValue); m_valueChanged = true; } /* @@ -244,8 +244,8 @@ void VarTree::inferTypesOfChildren(ProgramTypeTable& typeTable) // the value contains the pointer type in parenthesis bool VarTree::isWcharT() const { - return m_value.startsWith("(const wchar_t *)") || - m_value.startsWith("(wchar_t *)"); + return value().startsWith("(const wchar_t *)") || + value().startsWith("(wchar_t *)"); } /* @@ -600,8 +600,8 @@ void ExprWnd::collectUnknownTypes(VarTree* var) { var->m_type = TypeInfo::wchartType(); // see updateSingleExpr() why we move the value - var->m_partialValue = formatWCharPointer(var->m_value); - var->m_value.truncate(0); + var->m_partialValue = formatWCharPointer(var->value()); + var->setValue(QString()); m_updateStruct.append(var); } } @@ -632,8 +632,8 @@ bool ExprWnd::collectUnknownTypes(KTreeViewItem* item, void* user) { var->m_type = TypeInfo::wchartType(); // see updateSingleExpr() why we move the value - var->m_partialValue = formatWCharPointer(var->m_value); - var->m_value.truncate(0); + var->m_partialValue = formatWCharPointer(var->value()); + var->setValue(QString()); tree->m_updateStruct.append(var); } } diff --git a/kdbg/exprwnd.h b/kdbg/exprwnd.h index 47824e6..a1140b5 100644 --- a/kdbg/exprwnd.h +++ b/kdbg/exprwnd.h @@ -28,7 +28,6 @@ public: NKaddress /* a dereferenced pointer */ }; NameKind m_nameKind; - QString m_value; bool m_valueChanged; TypeInfo* m_type; /* type of struct */ int m_exprIndex; /* used in struct value update */ @@ -54,8 +53,13 @@ public: /** returns whether the pointer is a wchar_t */ bool isWcharT() const; + void setValue(const QString& v) { m_value = v; } + QString value() const { return m_value; } VarTree* firstChild() const { return static_cast(getChild()); } VarTree* nextSibling() const { return static_cast(getSibling()); } + +private: + QString m_value; }; /** diff --git a/kdbg/gdbdriver.cpp b/kdbg/gdbdriver.cpp index fe4c8a5..8cfb6ca 100644 --- a/kdbg/gdbdriver.cpp +++ b/kdbg/gdbdriver.cpp @@ -2495,7 +2495,7 @@ QString GdbDriver::parseMemoryDump(const char* output, QList& memdum QString GdbDriver::editableValue(VarTree* value) { - const char* s = value->m_value.latin1(); + const char* s = value->value().latin1(); // if the variable is a pointer value that contains a cast, // remove the cast -- 2.11.4.GIT