From kdevelop-bugs Wed Jan 25 13:58:07 2006 From: kdevelop-bugs-admin () barney ! cs ! uni-potsdam ! de Date: Wed, 25 Jan 2006 13:58:07 +0000 To: kdevelop-bugs Subject: [Bug 118130] variables output gets lost on trying to expand **vars Message-Id: <20060125135807.28561.qmail () ktown ! kde ! org> X-MARC-Message: https://marc.info/?l=kdevelop-bugs&m=118306945008822 ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. http://bugs.kde.org/show_bug.cgi?id=118130 ghost cs msu su changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Additional Comments From ghost cs msu su 2006-01-25 14:58 ------- SVN commit 502255 by vprus: In variables widget, when clicking "+" on pointer variable, show pointed-to value as child item, as opposed to changing the value of the clicked item. The previous behaviour was not very intuitive and also made impossible viewing of variables of type "pointer to pointer to whatever". BUG: 118130 M +63 -12 variablewidget.cpp M +6 -0 variablewidget.h --- branches/kdevelop/3.4/languages/cpp/debugger/variablewidget.cpp #502254:502255 @ -820,7 +820,10 @ if (item->isActive()) item->trim(); // recurse else + { + kdDebug(9012) << "Killing " << child->text(0) << "\n"; delete item; + } } } child = nextChild; @ -873,7 +876,8 @ cache_(QCString()), dataType_(dataType), highlight_(false), - format_(natural) + format_(natural), + pointedTo_(0) { // User might have entered format together with expression: like // /x i1+i2 @ -931,13 +935,20 @ vPath = itemName.replace(QRegExp("^static "), "") + "." + vPath; } + + // If parent is 'p' and current item is '*p', we don't need + // to qualify "*p" with "p.". + for(;;) + { + const VarItem* parent = + dynamic_cast(item->parent()); + if (parent && parent->pointedTo_ == item) + item = parent; + else + break; + } } - if (isOpen() && dataType_ == typePointer) - // We're currently showing pointed-to value - vPath = "*" + vPath; - - char* modifier = 0; switch(format_) { @ -969,16 +980,28 @ // ************************************************************************** + +// FIXME: we have two method to set VarItem: this one +// and updateValue below. That's bad, must have just one. void VarItem::setText(int column, const QString &data) { QString strData=data; - if (!isActive() && isOpen() && dataType_ == typePointer) { - waitingForData(); - ((VariableTree*)listView())->expandItem(this); + setActive(); + // FIXME: the above is copy-pasted from updateValue. See comment + // before the current method. + if (pointedTo_) + { + pointedTo_->setActive(); + if (isOpen()) + { + waitingForData(); + emit ((VariableTree*)listView())->expandItem(pointedTo_); + } + else + pointedToDirty_ = true; } - setActive(); if (column == ValueCol) { QString oldValue(text(column)); if (!oldValue.isEmpty()) // Don't highlight new items @ -1042,6 +1065,22 @ GDBParser::getGDBParser()->parseValue(this, r.data()); setActive(); + + if (pointedTo_) + { + pointedTo_->setActive(); + + // We don't fetch pointed-to data unless the item is open. + // On the other hand, we also don't delete pointedTo_ when + // this is closed, to avoid unnecessary "whatis" gdb queries. + if (isOpen()) + { + waitingForData(); + emit ((VariableTree*)listView())->expandItem(pointedTo_); + } + else + pointedToDirty_ = true; + } } // ************************************************************************** @ -1092,7 +1131,19 @ handleSpecialTypes(); trim(); } else { - if (dataType_ == typePointer || dataType_ == typeReference) { + if (dataType_ == typePointer) + { + if (!pointedTo_) + { + pointedTo_ = new VarItem(this, "*" + name_, typeUnknown); + pointedTo_->setRenameEnabled(0, 1); + pointedToDirty_ = true; + } + + if (pointedToDirty_) + emit ((VariableTree*)listView())->expandItem(pointedTo_); + } + else if (dataType_ == typeReference) { waitingForData(); emit ((VariableTree*)listView())->expandItem(this); } @ -1100,7 +1151,7 @ } else { // Closing item. For pointer/references, it means we switch from // display the pointer-to value to displaying the pointer itself. - if (dataType_ == typePointer || dataType_ == typeReference) { + if (dataType_ == typeReference) { waitingForData(); emit ((VariableTree*)listView())->expandItem(this); } --- branches/kdevelop/3.4/languages/cpp/debugger/variablewidget.h #502254:502255 @ -270,6 +270,12 @ QCString originalValueType_; format_t format_; + + // If 'this' has pointer type, points to child + // corresponding to deferences value. + // Can be 0 if this item was never opened. + VarItem* pointedTo_; + bool pointedToDirty_; }; /***************************************************************************/