From b5ad5835ea66834fc3ba400f28a38ce23964059b Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 19 Nov 2010 09:39:50 +0100 Subject: [PATCH] debugger: fix thread name display in threads combobox --- src/plugins/debugger/threaddata.h | 24 ++++++------- src/plugins/debugger/threadshandler.cpp | 46 ++++++++++++------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/plugins/debugger/threaddata.h b/src/plugins/debugger/threaddata.h index aaa4c92bb66..9c81fe1c497 100644 --- a/src/plugins/debugger/threaddata.h +++ b/src/plugins/debugger/threaddata.h @@ -45,13 +45,9 @@ namespace Internal { /*! A structure containing information about a single thread */ struct ThreadData { - inline ThreadData(quint64 threadid = 0) - : id (threadid) - , frameLevel(-1) - , address (0) - , lineNumber(-1) - { - } + ThreadData(quint64 threadid = 0) + : id(threadid), frameLevel(-1), address (0), lineNumber(-1) + {} enum { IdColumn, @@ -65,13 +61,7 @@ struct ThreadData ColumnCount = CoreColumn }; - // Permanent data. - quint64 id; - QString targetId; - QString core; - - // State information when stopped - inline void notifyRunning() // Clear state information + void notifyRunning() // Clear state information. { address = 0; function.clear(); @@ -81,6 +71,12 @@ struct ThreadData lineNumber = -1; } + // Permanent data. + quint64 id; + QString targetId; + QString core; + + // State information when stopped. qint32 frameLevel; quint64 address; QString function; diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index bc076c7b05b..15ff97acea2 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -46,30 +46,28 @@ namespace Internal { static QString threadToolTip(const ThreadData &thread) { - const char tableRowStartC[] = ""; - const char tableRowSeparatorC[] = ""; - const char tableRowEndC[] = ""; + const char start[] = ""; + const char sep[] = ""; + const char end[] = ""; QString rc; QTextStream str(&rc); str << "" - << tableRowStartC << ThreadsHandler::tr("Thread id:") - << tableRowSeparatorC << thread.id << tableRowEndC; + << start << ThreadsHandler::tr("Thread id:") + << sep << thread.id << end; if (!thread.targetId.isEmpty()) - str << tableRowStartC << ThreadsHandler::tr("Target id:") - << tableRowSeparatorC << thread.targetId << tableRowEndC; + str << start << ThreadsHandler::tr("Target id:") + << sep << thread.targetId << end; if (!thread.name.isEmpty()) - str << tableRowStartC << ThreadsHandler::tr("Name:") - << tableRowSeparatorC << thread.name << tableRowEndC; + str << start << ThreadsHandler::tr("Name:") + << sep << thread.name << end; if (!thread.state.isEmpty()) - str << tableRowStartC << ThreadsHandler::tr("State:") - << tableRowSeparatorC << thread.state << tableRowEndC; + str << start << ThreadsHandler::tr("State:") + << sep << thread.state << end; if (!thread.core.isEmpty()) - str << tableRowStartC << ThreadsHandler::tr("Core:") - << tableRowSeparatorC << thread.core << tableRowEndC; - + str << start << ThreadsHandler::tr("Core:") + << sep << thread.core << end; if (thread.address) { - str << tableRowStartC << ThreadsHandler::tr("Stopped at:") - << tableRowSeparatorC; + str << start << ThreadsHandler::tr("Stopped at:") << sep; if (!thread.function.isEmpty()) str << thread.function << "
"; if (!thread.fileName.isEmpty()) @@ -97,7 +95,7 @@ ThreadsHandler::ThreadsHandler() int ThreadsHandler::rowCount(const QModelIndex &parent) const { - // Since the stack is not a tree, row count is 0 for any valid parent + // Since the stack is not a tree, row count is 0 for any valid parent. return parent.isValid() ? 0 : m_threads.size(); } @@ -136,14 +134,14 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const case ThreadData::StateColumn: return thread.state; case ThreadData::NameColumn: - if (thread.name.isEmpty()) - return thread.id; - return thread.name; + if (!thread.name.isEmpty()) + return thread.name; + return thread.id; } case Qt::ToolTipRole: return threadToolTip(thread); case Qt::DecorationRole: - // Return icon that indicates whether this is the active stack frame + // Return icon that indicates whether this is the active stack frame. if (index.column() == 0) return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon; break; @@ -191,7 +189,7 @@ void ThreadsHandler::setCurrentThread(int index) if (index == m_currentIndex) return; - // Emit changed for previous frame + // Emit changed for previous frame. QModelIndex i = ThreadsHandler::index(m_currentIndex, 0); emit dataChanged(i, i); @@ -215,7 +213,7 @@ void ThreadsHandler::setCurrentThreadId(int id) int ThreadsHandler::indexOf(quint64 threadId) const { const int count = m_threads.size(); - for(int i = 0; i < count; i++) + for (int i = 0; i < count; ++i) if (m_threads.at(i).id == threadId) return i; return -1; @@ -279,7 +277,7 @@ Threads ThreadsHandler::parseGdbmiThreads(const GdbMi &data, int *currentThread) thread.fileName = QString::fromLatin1(frame.findChild("fullname").data()); thread.lineNumber = frame.findChild("line").data().toInt(); // Non-GDB (Cdb2) output name here. - thread.name = frame.findChild("name").data().toInt(); + thread.name = QString::fromLatin1(frame.findChild("name").data()); threads.append(thread); } if (currentThread)