Skip to content

Commit 3e538d5

Browse files
committed
Fix MIDI import encoding issue on Windows
1 parent 1af0f08 commit 3e538d5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Diff for: include/ImportFilter.h

+5
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class EXPORT ImportFilter : public Plugin
7878
return m_file.read( _data, _len );
7979
}
8080

81+
inline QByteArray readAllData()
82+
{
83+
return m_file.readAll();
84+
}
85+
8186
inline void ungetChar( char _ch )
8287
{
8388
m_file.ungetChar( _ch );

Diff for: plugins/MidiImport/MidiImport.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
#include <QDomDocument>
2727
#include <QDir>
2828
#include <QApplication>
29+
#include <QFile>
2930
#include <QMessageBox>
3031
#include <QProgressDialog>
3132

33+
#include <sstream>
34+
3235
#include "MidiImport.h"
3336
#include "TrackContainer.h"
3437
#include "InstrumentTrack.h"
@@ -279,8 +282,6 @@ class smfMidiChannel
279282

280283
bool MidiImport::readSMF( TrackContainer* tc )
281284
{
282-
QString filename = file().fileName();
283-
closeFile();
284285

285286
const int preTrackSteps = 2;
286287
QProgressDialog pd( TrackContainer::tr( "Importing MIDI-file..." ),
@@ -291,7 +292,11 @@ bool MidiImport::readSMF( TrackContainer* tc )
291292

292293
pd.setValue( 0 );
293294

294-
Alg_seq_ptr seq = new Alg_seq(filename.toLocal8Bit(), true);
295+
std::stringstream stream;
296+
QByteArray arr = readAllData();
297+
stream.str(std::string(arr.constData(), arr.size()));
298+
299+
Alg_seq_ptr seq = new Alg_seq(stream, true);
295300
seq->convert_to_beats();
296301

297302
pd.setMaximum( seq->tracks() + preTrackSteps );

0 commit comments

Comments
 (0)