mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-17 19:24:52 -04:00
Ensure file opened successfully when loading sample (#5816)
This commit is contained in:
@@ -196,11 +196,10 @@ void SampleBuffer::update( bool _keep_settings )
|
||||
{
|
||||
// Use QFile to handle unicode file names on Windows
|
||||
QFile f(file);
|
||||
f.open(QIODevice::ReadOnly);
|
||||
SNDFILE * snd_file;
|
||||
SF_INFO sf_info;
|
||||
sf_info.format = 0;
|
||||
if( ( snd_file = sf_open_fd( f.handle(), SFM_READ, &sf_info, false ) ) != NULL )
|
||||
if (f.open(QIODevice::ReadOnly) && (snd_file = sf_open_fd(f.handle(), SFM_READ, &sf_info, false)))
|
||||
{
|
||||
f_cnt_t frames = sf_info.frames;
|
||||
int rate = sf_info.samplerate;
|
||||
@@ -396,8 +395,7 @@ f_cnt_t SampleBuffer::decodeSampleSF(QString _f,
|
||||
|
||||
// Use QFile to handle unicode file names on Windows
|
||||
QFile f(_f);
|
||||
f.open(QIODevice::ReadOnly);
|
||||
if( ( snd_file = sf_open_fd( f.handle(), SFM_READ, &sf_info, false ) ) != NULL )
|
||||
if (f.open(QIODevice::ReadOnly) && (snd_file = sf_open_fd(f.handle(), SFM_READ, &sf_info, false)))
|
||||
{
|
||||
frames = sf_info.frames;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user