mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-13 12:42:20 +00:00
Addressing crashes reported on the users list (#4839)
See https://groups.google.com/g/golden-cheetah-users/c/tn5TirOOVdk/m/MKYMpsdMAQAJ Plus a crash in PlanAdherenceWindow
This commit is contained in:
committed by
GitHub
parent
12d67dd79f
commit
b5a85f313b
@@ -2529,6 +2529,9 @@ IntervalOverviewItem::setData(RideItem *item)
|
||||
void
|
||||
IntervalOverviewItem::setData(RideItem *item, bool animate)
|
||||
{
|
||||
if (item == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (block) return;
|
||||
block = true;
|
||||
|
||||
@@ -561,7 +561,7 @@ class IntervalOverviewItem : public ChartSpaceItem
|
||||
BubbleViz *bubble;
|
||||
|
||||
bool block; // block when signals occur too quickly
|
||||
RideItem *item; // remember what we are showing
|
||||
QPointer<RideItem> item; // remember what we are showing
|
||||
IntervalItem *hover = nullptr; // currently being hovered
|
||||
|
||||
OverviewItemConfig *configwidget;
|
||||
|
||||
@@ -62,17 +62,22 @@ PlanAdherenceWindow::PlanAdherenceWindow(Context *context)
|
||||
});
|
||||
connect(context->athlete->rideCache, QOverload<RideItem*>::of(&RideCache::itemChanged), this, &PlanAdherenceWindow::updateActivitiesIfInRange);
|
||||
connect(context->athlete->seasons, &Seasons::seasonsChanged, this, [this]() {
|
||||
DateRange dr(this->context->currentSeason()->getStart(), this->context->currentSeason()->getEnd(), this->context->currentSeason()->getName());
|
||||
adherenceView->setDateRange(dr);
|
||||
});
|
||||
connect(context, &Context::seasonSelected, this, [this](Season const *season, bool changed) {
|
||||
if (changed || first) {
|
||||
first = false;
|
||||
DateRange dr(season->getStart(), season->getEnd(), season->getName());
|
||||
Season const * current = this->context->currentSeason();
|
||||
if (current != nullptr) {
|
||||
DateRange dr(current->getStart(), current->getEnd(), current->getName());
|
||||
adherenceView->setDateRange(dr);
|
||||
}
|
||||
});
|
||||
connect(context, &Context::seasonSelected, this, &PlanAdherenceWindow::updateActivities);
|
||||
connect(context, &Context::seasonSelected, this, [this](Season const *season, bool changed) {
|
||||
if (season != nullptr) {
|
||||
if (changed || first) {
|
||||
first = false;
|
||||
DateRange dr(season->getStart(), season->getEnd(), season->getName());
|
||||
adherenceView->setDateRange(dr);
|
||||
}
|
||||
}
|
||||
updateActivities();
|
||||
});
|
||||
connect(context, &Context::filterChanged, this, &PlanAdherenceWindow::updateActivities);
|
||||
connect(context, &Context::homeFilterChanged, this, &PlanAdherenceWindow::updateActivities);
|
||||
connect(context, &Context::rideAdded, this, &PlanAdherenceWindow::updateActivitiesIfInRange);
|
||||
|
||||
@@ -184,6 +184,17 @@ RideCache::~RideCache()
|
||||
{
|
||||
exiting = true;
|
||||
|
||||
if (estimator) {
|
||||
estimator->stop();
|
||||
if (! estimator->wait(5000)) {
|
||||
qWarning() << "Estimator did not stop in time, forcing termination.";
|
||||
estimator->terminate();
|
||||
estimator->wait();
|
||||
}
|
||||
delete estimator;
|
||||
estimator = nullptr;
|
||||
}
|
||||
|
||||
// cancel any refresh that may be running
|
||||
cancel();
|
||||
|
||||
|
||||
@@ -322,7 +322,8 @@ QVector<float> RideFileCache::meanMaxPowerFor(Context *context, QVector<float> &
|
||||
bool first = true;
|
||||
|
||||
// look at all the rides
|
||||
foreach (RideItem *item, context->athlete->rideCache->rides()) {
|
||||
QList<RideItem*> rides = context->athlete->rideCache->rides(); // Create a copy of the ride list to prevent a crash
|
||||
for (RideItem *item : rides) {
|
||||
|
||||
if (item->dateTime.date() < from || item->dateTime.date() > to) continue; // not one we want
|
||||
|
||||
@@ -409,13 +410,13 @@ QVector<float> RideFileCache::meanMaxPowerFor(Context *context, QVector<float>&w
|
||||
// read from cache and put straight into QVector memory
|
||||
// a little naughty but seems to work ok
|
||||
returning.resize(head.wattsMeanMaxCount);
|
||||
inFile.readRawData((char*)returning.constData(), head.wattsMeanMaxCount * sizeof(float));
|
||||
inFile.readRawData((char*)returning.data(), head.wattsMeanMaxCount * sizeof(float));
|
||||
|
||||
offset = offsetForMeanMax(head, RideFile::wattsKg) + sizeof(head);
|
||||
cacheFile.seek(qint64(offset));
|
||||
|
||||
wpk.resize(head.wattsKgMeanMaxCount);
|
||||
inFile.readRawData((char*)wpk.constData(), head.wattsKgMeanMaxCount * sizeof(float));
|
||||
inFile.readRawData((char*)wpk.data(), head.wattsKgMeanMaxCount * sizeof(float));
|
||||
for(int i=0; i<wpk.size(); i++) wpk[i] = wpk[i] / 100.00f;
|
||||
|
||||
//qDebug()<<"retrieved:"<<head.wattsMeanMaxCount<<"in:"<<start.elapsed()<<"ms";
|
||||
|
||||
@@ -245,7 +245,7 @@ Estimator::run()
|
||||
// lets extract the best performance of the week first.
|
||||
// only care about performances between 3-20 minutes.
|
||||
Performance bestperformance(end,0,0,0);
|
||||
for (int t=240; t<week.length() && t<3600; t++) {
|
||||
for (int t=240; t<week.length() && t<weekdates.length() && t<3600; t++) {
|
||||
|
||||
double p = double(week[t]);
|
||||
if (week[t]<=0) continue;
|
||||
|
||||
Reference in New Issue
Block a user