Changeset 30060 in osm


Ignore:
Timestamp:
2013-11-19T02:41:51+01:00 (11 years ago)
Author:
donvip
Message:

[josm_directupload] fix #josm9329 - NPE with GPX traces without storage file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java

    r30034 r30060  
    9292    // as we don't know its contents yet and therefore have a height of 0. This will
    9393    // lead to unnecessary scrollbars.
    94     private JMultilineLabel OutputDisplay = new JMultilineLabel(" ");
     94    private JMultilineLabel outputDisplay = new JMultilineLabel(" ");
    9595    private HistoryComboBox descriptionField;
    9696    private HistoryComboBox tagsField;
     
    162162        JPanel p = new JPanel(new GridBagLayout());
    163163
    164         OutputDisplay.setMaxWidth(findMaxDialogSize().width-10);
    165         p.add(OutputDisplay, GBC.eol());
     164        outputDisplay.setMaxWidth(findMaxDialogSize().width-10);
     165        p.add(outputDisplay, GBC.eol());
    166166
    167167        p.add(tagsLabel, GBC.eol().insets(0,10,0,0));
     
    179179
    180180    private void initTitleAndDescriptionFromGpxData(GpxData gpxData) {
    181       String description, title, tags = "";
     181      String description = "", title = "", tags = "";
    182182      if (gpxData != null) {
    183183          GpxTrack firstTrack = gpxData.tracks.iterator().next();
     
    187187          } else if (firstTrack != null && gpxData.tracks.size() == 1 && firstTrack.get("desc") != null) {
    188188              description = firstTrack.getString("desc");
    189           } else {
     189          } else if (gpxData.storageFile != null) {
    190190              description = gpxData.storageFile.getName().replaceAll("[&?/\\\\]"," ").replaceAll("(\\.[^.]*)$","");
    191191          }
    192           title = tr("Selected track: {0}", gpxData.storageFile.getName());
     192          if (gpxData.storageFile != null) {
     193              title = tr("Selected track: {0}", gpxData.storageFile.getName());
     194          }
    193195          Object meta_tags = gpxData.attr.get(GpxConstants.META_KEYWORDS);
    194196          if (meta_tags != null) {
     
    200202          title = tr("No GPX layer selected. Cannot upload a trace.");
    201203      }
    202       OutputDisplay.setText(title);
     204      outputDisplay.setText(title);
    203205      descriptionField.setText(description);
    204206      tagsField.setText(tags);
     
    246248                GuiHelper.runInEDT(new Runnable() {
    247249                    @Override public void run() {
    248                         OutputDisplay.setText(tr("Upload canceled"));
     250                        outputDisplay.setText(tr("Upload canceled"));
    249251                        buttons.get(0).setEnabled(true);
    250252                    }
     
    267269            GuiHelper.runInEDT(new Runnable() {
    268270                @Override public void run() {
    269                     OutputDisplay.setText(tr("Error while uploading"));
     271                    outputDisplay.setText(tr("Error while uploading"));
    270272                }
    271273            });
     
    325327        GuiHelper.runInEDT(new Runnable() {
    326328            @Override public void run() {
    327                 OutputDisplay.setText(success
     329                outputDisplay.setText(success
    328330                        ? tr("GPX upload was successful")
    329331                        : tr("Upload failed. Server returned the following message: ") + returnMsgEDT);
     
    409411        GuiHelper.runInEDT(new Runnable() {
    410412            @Override public void run() {
    411                 OutputDisplay.setText(errorsEDT);
     413                outputDisplay.setText(errorsEDT);
    412414            }
    413415        });
Note: See TracChangeset for help on using the changeset viewer.