aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-12 14:22:46 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-13 09:24:37 +0900
commite0c0ac5d5c7c218011278fbe57da291a7e10c8eb (patch)
tree85ad06d20621a0bed01ee4266e5e4f6bbc8e6838 /qt-ui/profile
parente1971e9425dfc5266fa1e15579ff36d2b17658da (diff)
downloadsubsurface-e0c0ac5d5c7c218011278fbe57da291a7e10c8eb.tar.gz
Rename getDiveById to get_dive_by_id to keep current c code organized.
This commit renames getDiveById to get_dive_by_id, and it also removes the Q_ASSERTS and if(!dive) return that the callers of this function were calling. If it has a Q_ASSERT this means that the dive must exist, so checking for nullness was bogus too. I've changed the assert (done in a silly C-Way. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/diveplotdatamodel.cpp4
-rw-r--r--qt-ui/profile/diveprofileitem.cpp7
-rw-r--r--qt-ui/profile/profilewidget2.cpp4
3 files changed, 5 insertions, 10 deletions
diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index ad2859b9e..990564fbb 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -178,9 +178,7 @@ void DivePlotDataModel::emitDataChanged()
void DivePlotDataModel::calculateDecompression()
{
- struct dive *d = getDiveById(id());
- if (!d)
- return;
+ struct dive *d = get_dive_by_diveid(id());
struct divecomputer *dc = select_dc(d);
init_decompression(d);
calculate_deco_information(d, dc, &pInfo, false);
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index c239d39a9..1615be87f 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -427,8 +427,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
int last_pressure[MAX_CYLINDERS] = { 0, };
int last_time[MAX_CYLINDERS] = { 0, };
struct plot_data *entry;
- struct dive *dive = getDiveById(dataModel->id());
- Q_ASSERT(dive != NULL);
+ struct dive *dive = get_dive_by_diveid(dataModel->id());
cyl = -1;
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
@@ -490,9 +489,7 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte
QPen pen;
pen.setCosmetic(true);
pen.setWidth(2);
- struct dive *d = getDiveById(dataModel->id());
- if (!d)
- return;
+ struct dive *d = get_dive_by_diveid(dataModel->id());
struct plot_data *entry = dataModel->data().entry;
Q_FOREACH(const QPolygonF & poly, polygons) {
for (int i = 1, count = poly.count(); i < count; i++, entry++) {
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 17eb2a3c4..d2d01a384 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -227,7 +227,7 @@ void ProfileWidget2::replot()
{
int diveId = dataModel->id();
dataModel->clear();
- plotDives(QList<dive *>() << getDiveById(diveId));
+ plotDives(QList<dive *>() << get_dive_by_diveid(diveId));
}
void ProfileWidget2::setupItemSizes()
@@ -808,7 +808,7 @@ void ProfileWidget2::changeGas()
int diveId = dataModel->id();
int o2, he;
int seconds = timeAxis->valueAt(scenePos);
- struct dive *d = getDiveById(diveId);
+ struct dive *d = get_dive_by_diveid(diveId);
validate_gas(gas.toUtf8().constData(), &o2, &he);
add_gas_switch_event(d, get_dive_dc(d, diveComputer), seconds, get_gasidx(d, o2, he));