From 1a98a65c23797ccb9fac74c0cc1f5b547e902df1 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Thu, 16 May 2013 00:18:22 -0400 Subject: [PATCH] Fix IllegalArgumentException in Colors view The return value of ColorDialog.getRGB can return null. Bug: 408074 Change-Id: I40277621ba3e63b610e1ad2e012263850c74f26e Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/12856 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Reviewed-by: Patrick Tasse IP-Clean: Patrick Tasse --- .../tmf/ui/views/colors/ColorsView.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java index eabe4ffaa5..436af2d0f4 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java @@ -41,6 +41,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -443,9 +444,12 @@ public class ColorsView extends TmfView { dialog.setRGB(colorSetting.getForegroundRGB()); dialog.setText(Messages.ColorsView_ForegroundDialogText); dialog.open(); - colorSetting.setForegroundRGB(dialog.getRGB()); - ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0])); - label.setForeground(colorSetting.getForegroundColor()); + RGB rgb = dialog.getRGB(); + if (rgb != null) { + colorSetting.setForegroundRGB(rgb); + ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0])); + label.setForeground(colorSetting.getForegroundColor()); + } }}); bgButton.addSelectionListener(new SelectionAdapter() { @@ -457,10 +461,13 @@ public class ColorsView extends TmfView { dialog.setRGB(colorSetting.getBackgroundRGB()); dialog.setText(Messages.ColorsView_BackgroundDialogText); dialog.open(); - colorSetting.setBackgroundRGB(dialog.getRGB()); - ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0])); - labelComposite.setBackground(colorSetting.getBackgroundColor()); - label.setBackground(colorSetting.getBackgroundColor()); + RGB rgb = dialog.getRGB(); + if (rgb != null) { + colorSetting.setBackgroundRGB(rgb); + ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0])); + labelComposite.setBackground(colorSetting.getBackgroundColor()); + label.setBackground(colorSetting.getBackgroundColor()); + } }}); final Button tickButton = new Button(this, SWT.PUSH); @@ -499,9 +506,12 @@ public class ColorsView extends TmfView { dialog.setRGB(colorSetting.getTickColorRGB()); dialog.setText(Messages.TickColorDialog_TickColorDialogTitle); dialog.open(); - colorSetting.setTickColorRGB(dialog.getRGB()); - ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0])); - refresh(); + RGB rgb = dialog.getRGB(); + if (rgb != null) { + colorSetting.setTickColorRGB(rgb); + ColorSettingsManager.setColorSettings(fColorSettings.toArray(new ColorSetting[0])); + refresh(); + } }}); final Button filterButton = new Button(this, SWT.PUSH); -- 2.34.1