Skip to content

Commit dea15d3

Browse files
committed
fixed compiler warnings
1 parent b2a8dfb commit dea15d3

4 files changed

Lines changed: 36 additions & 34 deletions

File tree

-699 Bytes
Loading

‎examples/dateaxes/dateaxes.cpp‎

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <QTextStream>
1313
#include "jkqtplotter/jkqtplotter.h"
1414
#include "jkqtplotter/graphs/jkqtpscatter.h"
15-
#include "jkqtplotter/graphs/jkqtpgeometric.h"
1615
#include "jkqtplotter/jkqtptools.h"
1716
#include "jkqtplotter/graphs/jkqtpfilledcurve.h"
1817

@@ -29,18 +28,19 @@ void drawWithDateAxis(JKQTPlotter& plot) {
2928
// the second to fourth columns contain a floating-point number
3029
// with temperature average, min and max
3130
QFile file(":/weatherdata_gelsenkirchen.csv");
32-
file.open(QFile::ReadOnly|QFile::Text);
33-
file.readLine(); // eat comment
34-
while (!file.atEnd()) {
35-
QString line=file.readLine();
36-
QTextStream in(&line);
37-
QStringList items=line.split(";");
38-
// date/time values are stored as doubles representing the corresponding number of milliseconds sind epoch
39-
date<<QDateTime::fromString(items[0], Qt::ISODate).toUTC().toMSecsSinceEpoch();
40-
// store Heidelbergs daily temperature
41-
temperature<<items[1].toDouble();
42-
temperature_min<<items[2].toDouble();
43-
temperature_max<<items[3].toDouble();
31+
if (file.open(QFile::ReadOnly|QFile::Text)) {
32+
file.readLine(); // eat comment
33+
while (!file.atEnd()) {
34+
QString line=file.readLine();
35+
QTextStream in(&line);
36+
QStringList items=line.split(";");
37+
// date/time values are stored as doubles representing the corresponding number of milliseconds sind epoch
38+
date<<QDateTime::fromString(items[0], Qt::ISODate).toUTC().toMSecsSinceEpoch();
39+
// store Heidelbergs daily temperature
40+
temperature<<items[1].toDouble();
41+
temperature_min<<items[2].toDouble();
42+
temperature_max<<items[3].toDouble();
43+
}
4444
}
4545

4646
// 3. add a plot for the data mean line (graphTemperature) and range (graphTemperatureRange)
@@ -110,18 +110,19 @@ void drawWithTimeAxis(JKQTPlotter& plot) {
110110
// semicolon separated data. The first column is a time
111111
// the second contain a floating-point number with temperatures
112112
QFile file(":/weatherdata_heidelberg_2018-10-14.csv");
113-
file.open(QFile::ReadOnly|QFile::Text);
114-
file.readLine(); // eat comment
115-
while (!file.atEnd()) {
116-
QString line=file.readLine();
117-
QTextStream in(&line);
118-
QStringList items=line.split(";");
119-
// date/time values are stored as doubles representing the corresponding
120-
// number of milliseconds sind epoch. Since the data is time only, we have to use an arbitrary
121-
// date as basis
122-
time<<QDateTime::fromString("1970-01-01T"+items[0], Qt::ISODate).toMSecsSinceEpoch();
123-
// store Heidelbergs daily temperature
124-
temperature<<items[1].toDouble();
113+
if (file.open(QFile::ReadOnly|QFile::Text)) {
114+
file.readLine(); // eat comment
115+
while (!file.atEnd()) {
116+
QString line=file.readLine();
117+
QTextStream in(&line);
118+
QStringList items=line.split(";");
119+
// date/time values are stored as doubles representing the corresponding
120+
// number of milliseconds sind epoch. Since the data is time only, we have to use an arbitrary
121+
// date as basis
122+
time<<QDateTime::fromString("1970-01-01T"+items[0], Qt::ISODate).toMSecsSinceEpoch();
123+
// store Heidelbergs daily temperature
124+
temperature<<items[1].toDouble();
125+
}
125126
}
126127

127128
// 3. add a plot for the data mean line (graphTemperature) and range (graphTemperatureRange)

‎examples/mandelbrot/mandelbrotmainwindow.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void MandelbrotMainWindow::calculateMandelSet(double rmin, double rmax, double i
148148

149149
std::vector<std::thread> threads;
150150
for (size_t offset=0; offset<width*height; offset+=blocksize) {
151-
threads.push_back(std::thread([=](){
151+
threads.push_back(std::thread([ds,this,offset,blocksize,rmin, rmax, imin, imax, width, height, max_iterations](){
152152
// start iterating at begin+offset
153153
auto pix=ds->begin(mandelbrot_col)+static_cast<int>(offset);
154154
// stop iterating at begin+offset+blocksize, or at the end

‎lib/jkqtplotter/jkqtpbaseplotter.cpp‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ JKQTBasePlotter::~JKQTBasePlotter(){
322322
delete mainKey;
323323
delete xAxis;
324324
delete yAxis;
325-
for (const auto& ax: qAsConst(secondaryYAxis)) {
326-
delete ax;
325+
for (auto it=secondaryYAxis.begin(); it!=secondaryYAxis.end(); ++it) {
326+
delete it.value();
327327
}
328328
secondaryYAxis.clear();
329-
for (const auto& ax: qAsConst(secondaryXAxis)) {
330-
delete ax;
329+
for (auto it=secondaryXAxis.begin(); it!=secondaryXAxis.end(); ++it) {
330+
delete it.value();
331331
}
332332
secondaryXAxis.clear();
333333

@@ -932,15 +932,16 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
932932
if (s.elongateMax>0) elongateTop=qMin(elongateTop,s.elongateMax);
933933
internalPlotMargins[PlotMarginUse::muAxesOutside].right+=s.requiredSize;
934934

935-
936935
// read size required by secondary axes
937-
for (const auto& ax: qAsConst(secondaryYAxis)) {
936+
for (auto it=secondaryYAxis.begin(); it!=secondaryYAxis.end(); ++it) {
937+
auto ax= it.value();
938938
const auto s1=ax->getSize1(painter);
939939
const auto s2=ax->getSize2(painter);
940940
internalPlotMargins[PlotMarginUse::muAxesOutside].left+=s1.requiredSize+((fabs(s1.requiredSize)>0.1)?pt2px(painter, plotterStyle.secondaryAxisSeparation):0.0);
941941
internalPlotMargins[PlotMarginUse::muAxesOutside].right+=s2.requiredSize+((fabs(s2.requiredSize)>0.1)?pt2px(painter, plotterStyle.secondaryAxisSeparation):0.0);
942942
}
943-
for (const auto& ax: qAsConst(secondaryXAxis)) {
943+
for (auto it=secondaryXAxis.begin(); it!=secondaryXAxis.end(); ++it) {
944+
auto ax= it.value();
944945
const auto s1=ax->getSize1(painter);
945946
const auto s2=ax->getSize2(painter);
946947
internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=s1.requiredSize+((fabs(s1.requiredSize)>0.1)?pt2px(painter, plotterStyle.secondaryAxisSeparation):0.0);
@@ -3729,7 +3730,7 @@ bool JKQTBasePlotter::saveImage(const QString& filename, bool displayPreview) {
37293730
#else
37303731
QSharedPointer<QTemporaryFile> tf=QSharedPointer<QTemporaryFile>(new QTemporaryFile());
37313732
#endif
3732-
tf->open();
3733+
const bool ok=tf->open();
37333734
tempFM=tf->fileName();
37343735
tf->close();
37353736
tf.reset();

0 commit comments

Comments
 (0)