From 5266f16cc68090a99e22cc7d5d980a03c0d9cdf9 Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Fri, 3 Apr 2009 13:39:14 +0200
Subject: [PATCH] debugger: new test case for char arrays

---
 src/plugins/debugger/debuggeractions.cpp    |  3 +++
 src/plugins/debugger/debuggeractions.h      |  1 +
 src/plugins/debugger/watchhandler.cpp       |  8 +++++---
 src/plugins/debugger/watchwindow.cpp        | 12 ++++++++++--
 tests/manual/gdbdebugger/simple/app.cpp     | 10 ++++++++++
 tests/manual/gdbdebugger/simple/app/app.pro |  2 +-
 6 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp
index b8bc4dad5a1..6d90a3f7bed 100644
--- a/src/plugins/debugger/debuggeractions.cpp
+++ b/src/plugins/debugger/debuggeractions.cpp
@@ -149,6 +149,9 @@ DebuggerSettings *theDebuggerSettings()
     item = new SavedAction(instance);
     instance->insertItem(AssignValue, item);
 
+    item = new SavedAction(instance);
+    instance->insertItem(AssignType, item);
+
     item = new SavedAction(instance);
     instance->insertItem(ExpandItem, item);
     item->setText(QObject::tr("Expand item"));
diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h
index 079a879bc79..95167153e18 100644
--- a/src/plugins/debugger/debuggeractions.h
+++ b/src/plugins/debugger/debuggeractions.h
@@ -86,6 +86,7 @@ enum DebuggerActionCode
     WatchModelUpdate,
     UseToolTips,
     AssignValue,
+    AssignType,
     ExpandItem,
     CollapseItem,
 
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index af120e3a18c..b2af8278d94 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -520,9 +520,11 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const
     const WatchData &data = m_displaySet.at(node);
 
     if (data.isWatcher() && idx.column() == 0)
-        return editable; // watcher names are
-    if (idx.column() == 1) 
-        return editable; // values are editable
+        return editable; // watcher names are editable
+    if (data.isWatcher() && idx.column() == 2)
+        return editable; // watcher types are
+    if (idx.column() == 1)
+        return editable; // locals and watcher values are editable
     return  notEditable;
 }
 
diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp
index e10d39319b6..77f09f79208 100644
--- a/src/plugins/debugger/watchwindow.cpp
+++ b/src/plugins/debugger/watchwindow.cpp
@@ -87,6 +87,9 @@ public:
         if (index.column() == 1) {
             // the value column
             theDebuggerAction(AssignValue)->trigger(exp + '=' + value);
+        } else if (index.column() == 2) {
+            // the type column
+            theDebuggerAction(AssignType)->trigger(exp + '=' + value);
         } else if (index.column() == 0) {
             // the watcher name column
             theDebuggerAction(RemoveWatchExpression)->trigger(exp);
@@ -139,11 +142,16 @@ void WatchWindow::collapseNode(const QModelIndex &idx)
 
 void WatchWindow::keyPressEvent(QKeyEvent *ev)
 {
-    if (ev->key() == Qt::Key_Delete) {
+    if (ev->key() == Qt::Key_Delete && m_type == WatchersType) {
         QModelIndex idx = currentIndex();
         QModelIndex idx1 = idx.sibling(idx.row(), 0);
         QString exp = model()->data(idx1).toString();
-        theDebuggerAction(RemoveWatchExpression)->setValue(exp);
+        theDebuggerAction(RemoveWatchExpression)->trigger(exp);
+    } else if (ev->key() == Qt::Key_Return && m_type == LocalsType) {
+        QModelIndex idx = currentIndex();
+        QModelIndex idx1 = idx.sibling(idx.row(), 0);
+        QString exp = model()->data(idx1).toString();
+        theDebuggerAction(WatchExpression)->trigger(exp);
     }
     QTreeView::keyPressEvent(ev);
 }
diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp
index 9ff77312df2..8b51d7f8b76 100644
--- a/tests/manual/gdbdebugger/simple/app.cpp
+++ b/tests/manual/gdbdebugger/simple/app.cpp
@@ -116,6 +116,12 @@ private:
 
 void testArray()
 {
+    char c[20];
+    c[0] = 'a';
+    c[1] = 'b';
+    c[2] = 'c';
+    c[3] = 'd';
+
     QString x[20];
     x[0] = "a";
     x[1] = "b";
@@ -407,6 +413,10 @@ void testQObject(int &argc, char *argv[])
     QAction act("xxx", &app);
     QString t = act.text();
     t += "y";
+    t += "y";
+    t += "y";
+    t += "y";
+    t += "y";
 
 /*
     QObject ob(&app);
diff --git a/tests/manual/gdbdebugger/simple/app/app.pro b/tests/manual/gdbdebugger/simple/app/app.pro
index ab98e906f48..2210857b6a2 100644
--- a/tests/manual/gdbdebugger/simple/app/app.pro
+++ b/tests/manual/gdbdebugger/simple/app/app.pro
@@ -8,4 +8,4 @@ DESTDIR = ..
 SOURCES += ../app.cpp
 QT += network
 
-mesage("this says <foo & bar>")
+message("this says <foo & bar>")
-- 
GitLab