Bugfix: Remove group separator when converting string to number
Fixes #240
This commit is contained in:
parent
9c319f97e5
commit
c673141f33
@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "fileformat.pb.h"
|
||||
|
||||
#include "xlocale.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QInputDialog>
|
||||
#include <QItemSelectionModel>
|
||||
@ -435,7 +437,7 @@ void PortsWindow::on_averagePacketsPerSec_editingFinished()
|
||||
Q_ASSERT(plm->isPort(current));
|
||||
|
||||
bool isOk;
|
||||
double pps = QLocale().toDouble(averagePacketsPerSec->text(), &isOk);
|
||||
double pps = XLocale().toDouble(averagePacketsPerSec->text(), &isOk);
|
||||
|
||||
plm->port(current).setAveragePacketRate(pps);
|
||||
}
|
||||
@ -450,7 +452,7 @@ void PortsWindow::on_averageBitsPerSec_editingFinished()
|
||||
Q_ASSERT(plm->isPort(current));
|
||||
|
||||
bool isOk;
|
||||
double bps = QLocale().toDouble(averageBitsPerSec->text(), &isOk);
|
||||
double bps = XLocale().toDouble(averageBitsPerSec->text(), &isOk);
|
||||
|
||||
plm->port(current).setAverageBitRate(bps);
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include "../common/protocolmanager.h"
|
||||
#include "../common/protocolwidgetfactory.h"
|
||||
|
||||
#include "xlocale.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QMessageBox>
|
||||
|
||||
@ -1124,9 +1126,9 @@ void StreamConfigDialog::StoreCurrentStream()
|
||||
pStream->setNumBursts(leNumBursts->text().toULong(&isOk));
|
||||
pStream->setBurstSize(lePacketsPerBurst->text().toULong(&isOk));
|
||||
pStream->setPacketRate(
|
||||
QLocale().toDouble(lePacketsPerSec->text(), &isOk));
|
||||
XLocale().toDouble(lePacketsPerSec->text(), &isOk));
|
||||
pStream->setBurstRate(
|
||||
QLocale().toDouble(leBurstsPerSec->text(), &isOk));
|
||||
XLocale().toDouble(leBurstsPerSec->text(), &isOk));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1172,7 +1174,7 @@ void StreamConfigDialog::on_lePacketsPerSec_textChanged(const QString &text)
|
||||
|
||||
if (rbSendPackets->isChecked())
|
||||
{
|
||||
double pktsPerSec = QLocale().toDouble(text, &isOk);
|
||||
double pktsPerSec = XLocale().toDouble(text, &isOk);
|
||||
double bitsPerSec = pktsPerSec * double((frameLen+kEthFrameOverHead)*8);
|
||||
|
||||
if (rbPacketsPerSec->isChecked())
|
||||
@ -1197,7 +1199,7 @@ void StreamConfigDialog::on_leBurstsPerSec_textChanged(const QString &text)
|
||||
|
||||
if (rbSendBursts->isChecked())
|
||||
{
|
||||
double burstsPerSec = QLocale().toDouble(text, &isOk);
|
||||
double burstsPerSec = XLocale().toDouble(text, &isOk);
|
||||
double bitsPerSec = burstsPerSec *
|
||||
double(burstSize * (frameLen + kEthFrameOverHead) * 8);
|
||||
if (rbBurstsPerSec->isChecked())
|
||||
@ -1222,13 +1224,13 @@ void StreamConfigDialog::on_leBitsPerSec_textEdited(const QString &text)
|
||||
|
||||
if (rbSendPackets->isChecked())
|
||||
{
|
||||
double pktsPerSec = QLocale().toDouble(text, &isOk)/
|
||||
double pktsPerSec = XLocale().toDouble(text, &isOk)/
|
||||
double((frameLen+kEthFrameOverHead)*8);
|
||||
lePacketsPerSec->setText(QString("%L1").arg(pktsPerSec, 0, 'f', 4));
|
||||
}
|
||||
else if (rbSendBursts->isChecked())
|
||||
{
|
||||
double burstsPerSec = QLocale().toDouble(text, &isOk)/
|
||||
double burstsPerSec = XLocale().toDouble(text, &isOk)/
|
||||
double(burstSize * (frameLen + kEthFrameOverHead) * 8);
|
||||
leBurstsPerSec->setText(QString("%L1").arg(burstsPerSec, 0, 'f', 4));
|
||||
}
|
||||
|
35
client/xlocale.h
Normal file
35
client/xlocale.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright (C) 2018 Srivats P.
|
||||
|
||||
This file is part of "Ostinato"
|
||||
|
||||
This is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef _X_LOCALE_H
|
||||
#define _X_LOCALE_H
|
||||
|
||||
#include <QLocale>
|
||||
|
||||
class XLocale: public QLocale
|
||||
{
|
||||
public:
|
||||
double toDouble(const QString &s, bool *ok = Q_NULLPTR) const {
|
||||
QString s2 = s;
|
||||
return QLocale::toDouble(s2.remove(groupSeparator()), ok);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user