Skip to content

Commit

Permalink
fix #308694 fixed open files with the path name that contains non-ASC…
Browse files Browse the repository at this point in the history
…II characters for export audio
  • Loading branch information
igorkorsukov committed Sep 2, 2020
1 parent a8a1554 commit 2d173c5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mscore/exportaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================

#include <QFile>

#include "config.h"
#ifdef HAS_AUDIOFILE
#include <sndfile.h>
Expand Down Expand Up @@ -223,6 +225,7 @@ bool MuseScore::saveAudio(Score* score, const QString& name)
SF_INFO info;
SNDFILE *sf = nullptr;
const QString filename;
QFile file;
public:
SoundFileDevice(int sampleRate, int format, const QString& name)
: filename(name) {
Expand Down Expand Up @@ -254,7 +257,12 @@ bool MuseScore::saveAudio(Score* score, const QString& name)
if ((mode & QIODevice::WriteOnly) == 0) {
return false;
}
sf = sf_open(qPrintable(filename), SFM_WRITE, &info);

file.setFileName(filename);
if (!file.open(mode)) {
return false;
}
sf = sf_open_fd(file.handle(), SFM_WRITE, &info, false);
if (sf == nullptr) {
qDebug("open soundfile failed: %s", sf_strerror(sf));
return false;
Expand All @@ -266,6 +274,7 @@ bool MuseScore::saveAudio(Score* score, const QString& name)
qDebug("close soundfile failed");
}
sf = nullptr;
file.close();
QIODevice::close();
}
};
Expand Down

0 comments on commit 2d173c5

Please sign in to comment.