aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2017-05-08 16:40:59 +0300
committerKari Oikarinen <kari.oikarinen@qt.io>2017-05-18 10:09:16 +0000
commit9ea07a2fbc9f3aa6f313b3dfb826363b76bfe51f (patch)
tree5a45af65642e04f5dc73b1d9ac2d01dc67871230 /src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp
parent6dc6eb9ad0485f611e2eb49791475b3dd28e9aa0 (diff)
RemoteLinux: Don't force value for DISPLAY in base environment
When set on nVidia Jetson TX-1, it leads to applications failing. To allow previously created projects to work, add DISPLAY=:0.0 to user changes to the base environment the first time the project is loaded. On new projects for devices using X11 the user now has to manually set the DISPLAY variable. Task-number: QTBUG-60665 Change-Id: Iecc192fbad81ad5cbbbcabce6aeb28c3f501d022 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp')
-rw-r--r--src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp b/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp
index d821945a13e..c9910d5d09b 100644
--- a/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp
+++ b/src/plugins/remotelinux/remotelinuxenvironmentaspect.cpp
@@ -26,6 +26,22 @@
#include "remotelinuxenvironmentaspect.h"
#include "remotelinuxenvironmentaspectwidget.h"
+#include "utils/algorithm.h"
+
+static const char DISPLAY_KEY[] = "DISPLAY";
+static const char VERSION_KEY[] = "RemoteLinux.EnvironmentAspect.Version";
+static const int ENVIRONMENTASPECT_VERSION = 1; // Version was introduced in 4.3 with the value 1
+
+namespace {
+
+bool displayAlreadySet(const QList<Utils::EnvironmentItem> &changes)
+{
+ return Utils::contains(changes, [](const Utils::EnvironmentItem &item) {
+ return item.name == DISPLAY_KEY;
+ });
+}
+
+} // anonymous namespace
namespace RemoteLinux {
@@ -64,9 +80,6 @@ Utils::Environment RemoteLinuxEnvironmentAspect::baseEnvironment() const
Utils::Environment env;
if (baseEnvironmentBase() == static_cast<int>(RemoteBaseEnvironment))
env = m_remoteEnvironment;
- const QString displayKey = QLatin1String("DISPLAY");
- if (!env.hasKey(displayKey))
- env.appendOrSet(displayKey, QLatin1String(":0.0"));
return env;
}
@@ -93,5 +106,29 @@ QString RemoteLinuxEnvironmentAspect::userEnvironmentChangesAsString() const
return env.mid(0, env.size() - 1);
}
+void RemoteLinuxEnvironmentAspect::fromMap(const QVariantMap &map)
+{
+ ProjectExplorer::EnvironmentAspect::fromMap(map);
+
+ const auto version = map.value(QLatin1String(VERSION_KEY), 0).toInt();
+ if (version == 0) {
+ // In Qt Creator versions prior to 4.3 RemoteLinux included DISPLAY=:0.0 in the base
+ // environment, if DISPLAY was not set. In order to keep existing projects expecting
+ // that working, add the DISPLAY setting to user changes in them. New projects will
+ // have version 1 and will not get DISPLAY set.
+ auto changes = userEnvironmentChanges();
+ if (!displayAlreadySet(changes)) {
+ changes.append(Utils::EnvironmentItem(QLatin1String(DISPLAY_KEY), QLatin1String(":0.0")));
+ setUserEnvironmentChanges(changes);
+ }
+ }
+}
+
+void RemoteLinuxEnvironmentAspect::toMap(QVariantMap &map) const
+{
+ ProjectExplorer::EnvironmentAspect::toMap(map);
+ map.insert(QLatin1String(VERSION_KEY), ENVIRONMENTASPECT_VERSION);
+}
+
} // namespace RemoteLinux