Skip to content

Commit 22f8968

Browse files
authored
Merge pull request #555 from ferdnyc/fix-deprecated-endl
Use Qt::endl with QTextStream
2 parents 131e441 + 92293d3 commit 22f8968

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

include/CacheDisk.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
#include "Frame.h"
3939
#include "Exceptions.h"
4040
#include <QDir>
41-
#include <QString>
42-
#include <QTextStream>
4341

4442
namespace openshot {
4543

include/QtUtilities.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @file
3+
* @brief Header file for QtUtilities (compatibiity overlay)
4+
* @author FeRD (Frank Dana) <[email protected]>
5+
*/
6+
7+
/* LICENSE
8+
*
9+
* Copyright (c) 2008-2020 OpenShot Studios, LLC
10+
* <http://www.openshotstudios.com/>. This file is part of
11+
* OpenShot Library (libopenshot), an open-source project dedicated to
12+
* delivering high quality video editing and animation solutions to the
13+
* world. For more information visit <http://www.openshot.org/>.
14+
*
15+
* OpenShot Library (libopenshot) is free software: you can redistribute it
16+
* and/or modify it under the terms of the GNU Lesser General Public License
17+
* as published by the Free Software Foundation, either version 3 of the
18+
* License, or (at your option) any later version.
19+
*
20+
* OpenShot Library (libopenshot) is distributed in the hope that it will be
21+
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
* GNU Lesser General Public License for more details.
24+
*
25+
* You should have received a copy of the GNU Lesser General Public License
26+
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
27+
*/
28+
29+
#ifndef OPENSHOT_QT_UTILITIES_H
30+
#define OPENSHOT_QT_UTILITIES_H
31+
32+
#include <Qt>
33+
#include <QTextStream>
34+
35+
// Fix Qt::endl for older Qt versions
36+
// From: https://bugreports.qt.io/browse/QTBUG-82680
37+
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
38+
namespace Qt {
39+
using TextStreamFunction = QTextStream& (*)(QTextStream&);
40+
constexpr TextStreamFunction endl = ::endl;
41+
}
42+
#endif
43+
44+
#endif // OPENSHOT_QT_UTILITIES_H

src/CacheDisk.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
*/
3030

3131
#include "../include/CacheDisk.h"
32+
#include "../include/QtUtilities.h"
33+
#include <Qt>
34+
#include <QString>
35+
#include <QTextStream>
3236

3337
using namespace std;
3438
using namespace openshot;
@@ -191,18 +195,18 @@ void CacheDisk::Add(std::shared_ptr<Frame> frame)
191195

192196
if (audio_file.open(QIODevice::WriteOnly)) {
193197
QTextStream audio_stream(&audio_file);
194-
audio_stream << frame->SampleRate() << endl;
195-
audio_stream << frame->GetAudioChannelsCount() << endl;
196-
audio_stream << frame->GetAudioSamplesCount() << endl;
197-
audio_stream << frame->ChannelsLayout() << endl;
198+
audio_stream << frame->SampleRate() << Qt::endl;
199+
audio_stream << frame->GetAudioChannelsCount() << Qt::endl;
200+
audio_stream << frame->GetAudioSamplesCount() << Qt::endl;
201+
audio_stream << frame->ChannelsLayout() << Qt::endl;
198202

199203
// Loop through all samples
200204
for (int channel = 0; channel < frame->GetAudioChannelsCount(); channel++)
201205
{
202206
// Get audio for this channel
203207
float *samples = frame->GetAudioSamples(channel);
204208
for (int sample = 0; sample < frame->GetAudioSamplesCount(); sample++)
205-
audio_stream << samples[sample] << endl;
209+
audio_stream << samples[sample] << Qt::endl;
206210
}
207211

208212
}

0 commit comments

Comments
 (0)