summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2023-12-14 11:25:04 +0200
committerKatja Marttila <katja.marttila@qt.io>2024-02-14 07:53:24 +0000
commitff5df69f6e7797001f715d9ab57426a101aae121 (patch)
tree0a296d479ce27fb8fdd4587b46697066e602331c /src
parent0d930fc4572cf9b98ec75718fab4a1eaecf0bc74 (diff)
Fix EnvironmentVariable undo
If EnvironmentVariable value contains both @TargetDir@ and hardcoded windows path separators, installer is unable to undo the EnvironmentVariable in uninstall. Fixed so that the path separators are ignored when comparing the values in undo. Another fix would be to use Linux native separators when setting the value, or resolve @TargetDir@, and calling installer.toNativeSeparators() before calling addOperation() Task-number: QTIFW-1148 Change-Id: I2eb8f9a0580e0c3f7e6dbdbef5ecbf6cd8940481 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/environmentvariablesoperation.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp
index 44fe7d657..94cd1e36f 100644
--- a/src/libs/installer/environmentvariablesoperation.cpp
+++ b/src/libs/installer/environmentvariablesoperation.cpp
@@ -30,6 +30,7 @@
#include "qsettingswrapper.h"
#include <stdlib.h>
+#include <QDir>
#include "environment.h"
#include "globals.h"
@@ -168,11 +169,11 @@ UpdateOperation::Error undoSetting(const QString &regPath,
if (actual != value)
{
- //For unknown reason paths with @TargetDir@ variable get modified
- //so that Windows file separators get replaced with unix style separators,
- //fix separators before matching to actual value in register
+ //Ignore the separators
+ static const QRegularExpression regex(QLatin1String("(\\\\|/)"));
QString tempValue = value;
- QString fixedValue = tempValue.replace(QLatin1Char('/'), QLatin1Char('\\'));
+ QString fixedValue = tempValue.replace(regex, QDir::separator());
+ actual = actual.replace(regex, QDir::separator());
if (actual != fixedValue) //key changed, don't undo
return UpdateOperation::UserDefinedError;