Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting a campaign with too short a name throws exception #1269

Closed
emmebi opened this issue Feb 9, 2020 · 6 comments
Closed

Exporting a campaign with too short a name throws exception #1269

emmebi opened this issue Feb 9, 2020 · 6 comments
Assignees
Labels
bug tested This issue has been QA tested by someone other than the developer.

Comments

@emmebi
Copy link
Collaborator

emmebi commented Feb 9, 2020

Describe the bug
Exporting a campaign with a short name causes an error

To Reproduce
Steps to reproduce the behavior:

  1. Launch MapTool
  2. Click on File -> Export -> Campaign As...
  3. Enter c1 as the campaign name
  4. Click ok
  5. The error message is shown

Expected behavior
The campaign to be saved as c1.cmpgn

Screenshots
Attached screenshot of the error

MapTool Info

  • Version: 1.5.12

Desktop (please complete the following information):

  • OS: Windows
  • Version 10

export_dialog_error

@Phergus Phergus added the bug label Feb 9, 2020
@Phergus
Copy link
Contributor

Phergus commented Feb 9, 2020

Is this specific to short names or the timing after starting MapTool?

Appears to be just a short name issue.

@emmebi
Copy link
Collaborator Author

emmebi commented Feb 9, 2020

Yes: I thought it had to do with the timing (and the fact that the campaign was not saved yet) but it turned out that you could reproduce the same also with a saved campaign.

@Phergus Phergus changed the title Exporting a campaign right after loading MapTool raises an error Exporting a campaign with too short a name throws exception Feb 9, 2020
@Phergus
Copy link
Contributor

Phergus commented Feb 9, 2020

Note that this is for the File -> Export action only.

@Merudo
Copy link
Member

Merudo commented Feb 10, 2020

If I remember right, it is related to the file extension.

@emmebi
Copy link
Collaborator Author

emmebi commented Feb 10, 2020

Correct, the problem is in the AppState.getCampaignName:

  public static String getCampaignName() {
    if (AppState.campaignFile == null) {
      return "Default";
    } else {
      String s = AppState.campaignFile.getName();
      // remove the file extension of the campaign file name
      return s.substring(0, s.length() - AppConstants.CAMPAIGN_FILE_EXTENSION.length());
    }
  }

As you can see, this assumes that the name has always an extension. Not posting a fix for this now because I will be busy with other stuff during the week; if this is still active during the week-end, I will create a fix for it :)

emmebi added a commit to emmebi/maptool that referenced this issue Feb 18, 2020
…ame in Export and Save

This is a fix for RPTools#1269. Since code between Export As and Save As is very similar, it has been
refactored out as much as possible.

This also fixes a problem in the Save As function: if you try to save the campaign as c1, it checks
if c1 exists, but then saves it as c1.cmpgn. Fixed.

Manual test cases:
Test Cases:

Export:
- existing file, no extension => OK
- not existing file, extension => OK
- not existing file, no extension => OK
- existing file, extension => OK

Save:
- existing file, no extension => OK
- not existing file, extension => OK
- not existing file, no extension => OK
- existing file, extension => OK

Refers to RPTools#1269
emmebi added a commit to emmebi/maptool that referenced this issue Feb 18, 2020
@Phergus Phergus added the tested This issue has been QA tested by someone other than the developer. label Feb 20, 2020
@Phergus
Copy link
Contributor

Phergus commented Feb 20, 2020

Tested. Exporting campaign files with as few as 1 character file names works as expected.

@Phergus Phergus closed this as completed Feb 20, 2020
Phergus added a commit that referenced this issue Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug tested This issue has been QA tested by someone other than the developer.
Projects
None yet
Development

No branches or pull requests

3 participants