From b0338c95ebd22bb87f3a592858cb96e50ff6d7b1 Mon Sep 17 00:00:00 2001 From: Alex Blewitt Date: Fri, 4 Jun 2010 19:49:05 +0100 Subject: [PATCH] Remember to dispose the clipboard after use Once the clipboard is acquired, we should dispose of it afterwards to prevent memory and resource leaks. Not all the text on the clipboard will be text; if it isn't, then we'll get a null back. Handle that case specifically. If the text begins (or ends) with whitespace, trim it before checking. Bug: 315589 Change-Id: I1b8eeae47b880b6eef689ca359f9c67e93e7e999 Signed-off-by: Alex Blewitt --- .../egit/ui/internal/components/RepositorySelectionPage.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java index f5d89526..0294c7b0 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RepositorySelectionPage.java @@ -171,12 +171,15 @@ public class RepositorySelectionPage extends BaseWizardPage { Clipboard clippy = new Clipboard(Display.getCurrent()); String text = (String) clippy.getContents(TextTransfer.getInstance()); try { - if(Transport.canHandleProtocol(new URIish(text))) { - preset = text; + if(text != null) { + text = text.trim(); + if(Transport.canHandleProtocol(new URIish(text))) + preset = text; } } catch (URISyntaxException e) { preset = null; } + clippy.dispose(); } this.presetUri = preset; -- 2.11.4.GIT