From 980eb1b25c877eb57897270223726714241a2751 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 27 Mar 2018 15:35:53 -0400 Subject: [PATCH] Bug 532967 - Meson config properties not being saved/restored properly - change splitting logic in MesonPropertyPage to split the arg string using -- which precedes args and to perform trim() operation to remove spaces between - don't process an empty arg after splitting - fix the boolean arg logic to use parseBoolean instead of getBoolean which is only for system properties Change-Id: I390911bbf9d7f63f0cf6a13278f3644fe175847b --- .../properties/IMesonPropertyPageControl.java | 2 +- .../ui/properties/MesonPropertyPage.java | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java index 757214687c6..1e47ea9714e 100644 --- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java +++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/IMesonPropertyPageControl.java @@ -46,7 +46,7 @@ public interface IMesonPropertyPageControl { /** * Get the command line parameter if never configured - * @return String containing command-line parm for configured build dir + * @return String containing command-line parm for unconfigured build dir */ default String getUnconfiguredString() { return "--" + getFieldName() + "=" + getFieldValue(); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java index 601284734c5..7cd4d18105e 100644 --- a/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java +++ b/build/org.eclipse.cdt.meson.ui/src/org/eclipse/cdt/meson/ui/properties/MesonPropertyPage.java @@ -134,13 +134,15 @@ public class MesonPropertyPage extends PropertyPage { Map argMap = new HashMap<>(); String mesonArgs = buildConfig.getProperty(IMesonConstants.MESON_ARGUMENTS); if (mesonArgs != null) { - String[] argStrings = mesonArgs.split("\\s+"); //$NON-NLS-1$ + String[] argStrings = mesonArgs.split("--"); //$NON-NLS-1$ for (String argString : argStrings) { - String[] s = argString.split("="); //$NON-NLS-1$ - if (s.length == 2) { - argMap.put(s[0], s[1]); - } else { - argMap.put(argString, "true"); //$NON-NLS-1$ + if (!argString.isEmpty()) { + String[] s = argString.split("="); //$NON-NLS-1$ + if (s.length == 2) { + argMap.put(s[0], s[1].trim()); + } else { + argMap.put(argString.trim(), "true"); //$NON-NLS-1$ + } } } } @@ -306,8 +308,10 @@ public class MesonPropertyPage extends PropertyPage { } else { StringBuilder mesonargs = new StringBuilder(); for (IMesonPropertyPageControl control : componentList) { - mesonargs.append(control.getUnconfiguredString()); - mesonargs.append(" "); //$NON-NLS-1$ + if (!control.getUnconfiguredString().isEmpty()) { + mesonargs.append(control.getUnconfiguredString()); + mesonargs.append(" "); //$NON-NLS-1$ + } } buildConfig.setProperty(IMesonConstants.MESON_ARGUMENTS, mesonargs.toString()); buildConfig.setProperty(IMesonConstants.MESON_ENV, envText.getText().trim()); @@ -366,7 +370,7 @@ public class MesonPropertyPage extends PropertyPage { } else { boolean defaultValue = false; if (argMap.containsKey(optionMatcher.group(2))) { - defaultValue = Boolean.getBoolean(argMap.get(optionMatcher.group(2))); + defaultValue = Boolean.parseBoolean(argMap.get(optionMatcher.group(2))); } IMesonPropertyPageControl control = new MesonPropertySpecialCheckbox(group, optionMatcher.group(2), defaultValue, optionMatcher.group(6)); controls.add(control);