Changeset 5149 in josm


Ignore:
Timestamp:
Apr 1, 2012 12:03:14 PM (14 months ago)
Author:
Don-vip
Message:

fix EDT violation after a download error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandler.java

    r3313 r5149  
    1010 
    1111import javax.swing.JOptionPane; 
     12import javax.swing.SwingUtilities; 
    1213 
    1314import org.openstreetmap.josm.Main; 
     
    8182        // 
    8283        if (errors.size() == 1) { 
    83             Object error = errors.iterator().next(); 
    84             if (error instanceof Exception) { 
    85                 ExceptionDialogUtil.explainException((Exception)error); 
    86                 return; 
    87             } 
    88             JOptionPane.showMessageDialog( 
    89                     Main.parent, 
    90                     error.toString(), 
    91                     tr("Error during download"), 
    92                     JOptionPane.ERROR_MESSAGE); 
     84            final Object error = errors.iterator().next(); 
     85            SwingUtilities.invokeLater(new Runnable() { 
     86                @Override 
     87                public void run() { 
     88                    if (error instanceof Exception) { 
     89                        ExceptionDialogUtil.explainException((Exception)error); 
     90                    } else { 
     91                        JOptionPane.showMessageDialog( 
     92                                Main.parent, 
     93                                error.toString(), 
     94                                tr("Error during download"), 
     95                                JOptionPane.ERROR_MESSAGE); 
     96                    } 
     97                } 
     98            }); 
    9399            return; 
    94  
    95100        } 
    96101 
     
    98103        // 
    99104        if (!errors.isEmpty()) { 
    100             StringBuffer sb = new StringBuffer(); 
     105            final StringBuffer sb = new StringBuffer(); 
    101106            for (Object error:errors) { 
    102107                if (error instanceof String) { 
     
    109114            sb.append("</ul></html>"); 
    110115 
    111             JOptionPane.showMessageDialog( 
    112                     Main.parent, 
    113                     sb.toString(), 
    114                     tr("Errors during download"), 
    115                     JOptionPane.ERROR_MESSAGE); 
     116            SwingUtilities.invokeLater(new Runnable() { 
     117                @Override 
     118                public void run() { 
     119                    JOptionPane.showMessageDialog( 
     120                            Main.parent, 
     121                            sb.toString(), 
     122                            tr("Errors during download"), 
     123                            JOptionPane.ERROR_MESSAGE); 
     124                } 
     125            }); 
    116126            return; 
    117127        } 
Note: See TracChangeset for help on using the changeset viewer.