diff --git a/src/plugins/projectexplorer/targetselector.cpp b/src/plugins/projectexplorer/targetselector.cpp
index 8c1286a558917d350c919204dc1af99b33c62187..869c236c1f9de6f081544208fb70c70a74d1598c 100644
--- a/src/plugins/projectexplorer/targetselector.cpp
+++ b/src/plugins/projectexplorer/targetselector.cpp
@@ -161,7 +161,7 @@ void TargetSelector::paintEvent(QPaintEvent *event)
             targetName = QChar('*') + target.name + QChar('*');
         else
             targetName = target.name;
-        p.drawText(x + (TARGET_WIDTH - fm.width(target.name))/2 + 1, 7 + fm.ascent(),
+        p.drawText(x + (TARGET_WIDTH - fm.width(targetName))/2 + 1, 7 + fm.ascent(),
             targetName);
         x += TARGET_WIDTH;
         p.drawLine(x, 1, x, TARGET_HEIGHT);