Index: trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java	(revision 15645)
+++ trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java	(revision 15646)
@@ -16,4 +16,5 @@
 import org.openstreetmap.josm.data.Bounds.ParseMethod;
 import org.openstreetmap.josm.data.ProjectionBounds;
+import org.openstreetmap.josm.data.gpx.GpxConstants;
 import org.openstreetmap.josm.data.gpx.GpxData;
 import org.openstreetmap.josm.gui.MainApplication;
@@ -34,4 +35,5 @@
 import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
+import org.openstreetmap.josm.tools.Utils;
 import org.xml.sax.SAXException;
 
@@ -44,5 +46,5 @@
     private GpxLayer gpxLayer;
 
-    protected String newLayerName;
+    protected String url;
 
     @Override
@@ -68,4 +70,5 @@
     public Future<?> loadUrl(DownloadParams settings, String url, ProgressMonitor progressMonitor) {
         CheckParameterUtil.ensureParameterNotNull(url, "url");
+        this.url = url;
         final Optional<String> mappedUrl = Stream.of(GpxUrlPattern.USER_TRACE_ID, GpxUrlPattern.EDIT_TRACE_ID)
                 .map(p -> Pattern.compile(p.pattern()).matcher(url))
@@ -81,7 +84,4 @@
             downloadTask = new DownloadTask(settings,
                     new OsmServerLocationReader(url), progressMonitor);
-            // Extract .gpx filename from URL to set the new layer name
-            Matcher matcher = Pattern.compile(GpxUrlPattern.EXTERNAL_GPX_FILE.pattern()).matcher(url);
-            newLayerName = matcher.matches() ? matcher.group(1) : null;
             // We need submit instead of execute so we can wait for it to finish and get the error
             // message if necessary. If no one calls getErrorMessage() it just behaves like execute.
@@ -139,5 +139,5 @@
             if (rawData == null)
                 return;
-            String name = newLayerName != null ? newLayerName : tr("Downloaded GPX Data");
+            String name = getLayerName();
 
             GpxImporterData layers = GpxImporter.loadLayers(rawData, reader.isGpxParsedProperly(), name,
@@ -149,4 +149,18 @@
 
             layers.getPostLayerTask().run();
+        }
+
+        private String getLayerName() {
+            // Extract .gpx filename from URL to set the new layer name
+            final Matcher matcher = Pattern.compile(GpxUrlPattern.EXTERNAL_GPX_FILE.pattern()).matcher(url);
+            final String newLayerName = matcher.matches() ? matcher.group(1) : null;
+            final String metadataName = rawData != null ? rawData.getString(GpxConstants.META_NAME) : null;
+            final String defaultName = tr("Downloaded GPX Data");
+
+            if (Config.getPref().getBoolean("gpx.prefermetadataname", false)) {
+                return Utils.firstNotEmptyString(defaultName, metadataName, newLayerName);
+            } else {
+                return Utils.firstNotEmptyString(defaultName, newLayerName, metadataName);
+            }
         }
 
Index: trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 15645)
+++ trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 15646)
@@ -107,10 +107,9 @@
      */
     public GpxLayer(GpxData d, String name, boolean isLocal) {
-        super(d.getString(GpxConstants.META_NAME));
+        super(name);
         data = d;
         data.addWeakChangeListener(dataChangeListener);
         trackVisibility = new boolean[data.getTracks().size()];
         Arrays.fill(trackVisibility, true);
-        setName(name);
         isLocalFile = isLocal;
         ExpertToggleAction.addExpertModeChangeListener(this, true);
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 15645)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 15646)
@@ -747,4 +747,20 @@
 
     /**
+     * Returns the first not empty string in the given candidates, otherwise the default string.
+     * @param defaultString default string returned if all candidates would be empty if stripped
+     * @param candidates string candidates to consider
+     * @return the first not empty string in the given candidates, otherwise the default string
+     * @since 15646
+     */
+    public static String firstNotEmptyString(String defaultString, String... candidates) {
+        for (String candidate : candidates) {
+            if (!Utils.isStripEmpty(candidate)) {
+                return candidate;
+            }
+        }
+        return defaultString;
+    }
+
+    /**
      * Determines if the given String would be empty if stripped.
      * This is an efficient alternative to {@code strip(s).isEmpty()} that avoids to create useless String object.
