endless-sky / endless-sky-editor

Map editor for the Endless Sky universe.
GNU General Public License v3.0
68 stars 44 forks source link

fix for issue-31: Save button doesn't work #38

Closed maltedreschert closed 3 years ago

maltedreschert commented 3 years ago

The problem of the save functionality came from the fact that the QString::right() method expects the number of characters it should take from the end of the string forward. The lastIndexOf() method finds the last occurence of a character but returns the index from the beginning of the string. Now instead of counting length of "filename+extension" from the end, the right function counted the number of characters from the end, resulting in an invalid path in the save method. To reduce errors in this area I replaced the QString methods with the QFileInfo methods that take care of these things and is therefore more safe.

maltedreschert commented 3 years ago

I ordered the includes.