amakaseev / sprite-sheet-packer

Sprite sheet packer
MIT License
318 stars 62 forks source link

Crash when saving project in linux #72

Closed azagaya closed 4 years ago

azagaya commented 4 years ago

Hi, Saving a project on linux (tested in Ubuntu 19.10 with Qt 5.13) crashes. That's because the file dialog does not automatically adds the extension. I had the same problem for my own tool. I made a possible workarround here:

void MainWindow::on_actionSaveAs_triggered() {
    QSettings settings;
    QString dir;
    if (!_currentProjectFileName.isEmpty()) {
        dir = _currentProjectFileName;
    } else {
        dir = settings.value("spritePackerFileName", QDir::currentPath()).toString();
    }
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save sprite packer project file."),
                                                    dir,
                                                    tr("Sprite sheet packer (*.ssp)"));
    if (!fileName.isEmpty()) {
        if (!fileName.endsWith(".ssp")) {
            fileName.append(".ssp");
        }
        settings.setValue("spritePackerFileName", fileName);
        saveSpritePackerProject(fileName);
    }
}

Just added a verification that if the correct suffix is not added to the filename when saving, add it by default. I'll make a PR if that way suits your guidelines!

amakaseev commented 4 years ago

Yes of course! Thank you for improving the project:)