Index: trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 7987)
+++ trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java	(revision 7989)
@@ -463,4 +463,10 @@
 
         try {
+            // see #11026 - Because <ways> is a dynamic filtered (on ways) of a filtered (on selected objects) collection,
+            // retrieve effective dataset before joining the ways (which affects the selection, thus, the <ways> collection)
+            // Dataset retrieving allows to call this code without relying on Main.getCurrentDataSet(), thus, on a mapview instance
+            DataSet ds = ways.iterator().next().getDataSet();
+
+            // Do the job of joining areas
             JoinAreasResult result = joinAreas(areas);
 
@@ -478,5 +484,4 @@
                     allWays.addAll(pol.innerWays);
                 }
-                DataSet ds = ways.iterator().next().getDataSet();
                 if (ds != null) {
                     ds.setSelected(allWays);
