Skip to content

Commit

Permalink
Fixed crash when "Show Earth's umbra" is enabled (fix #2509)
Browse files Browse the repository at this point in the history
The issue is happened in debug mode
  • Loading branch information
alex-w committed Jul 12, 2022
1 parent b0e6649 commit b9ceeb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions plugins/Satellites/src/Satellites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,7 @@ void Satellites::draw(StelCore* core)
drawPointer(core, painter);

if (getFlagUmbraVisible())
drawCircles(core);
drawCircles(core, painter);
}

void Satellites::drawPointer(StelCore* core, StelPainter& painter)
Expand Down Expand Up @@ -2723,13 +2723,13 @@ void Satellites::drawPointer(StelCore* core, StelPainter& painter)
}
}

void Satellites::drawCircles(StelCore* core)
void Satellites::drawCircles(StelCore* core, StelPainter &painter)
{
StelPainter sPainter(core->getProjection(StelCore::FrameHeliocentricEclipticJ2000, StelCore::RefractionAuto));

sPainter.setBlending(true, GL_ONE, GL_ONE);
sPainter.setLineSmooth(true);
sPainter.setFont(labelFont);
StelProjectorP saveProj = painter.getProjector();
painter.setProjector(core->getProjection(StelCore::FrameHeliocentricEclipticJ2000, StelCore::RefractionAuto));
painter.setBlending(true, GL_ONE, GL_ONE);
painter.setLineSmooth(true);
painter.setFont(labelFont);

double lambda, beta, satDistance;
const Vec3d pos = earth->getEclipticPos();
Expand Down Expand Up @@ -2781,15 +2781,15 @@ void Satellites::drawCircles(StelCore* core)
rot.transfo(point);
umbra.vertex.append(pos+point);
}
sPainter.setColor(getUmbraColor(), 1.f);
sPainter.drawStelVertexArray(umbra, false);
painter.setColor(getUmbraColor(), 1.f);
painter.drawStelVertexArray(umbra, false);

Vec3d point(satDistance, 0.0, 0.0);
rot.transfo(point);
Vec3d coord = pos+point;
sPainter.drawSprite2dMode(coord, 5.f);
painter.drawSprite2dMode(coord, 5.f);
QString cuLabel = QString("%1 (h=%2 %3)").arg(q_("C.U."), QString::number(AU*(satDistance - earth->getEquatorialRadius()), 'f', 1), qc_("km","distance"));
sPainter.drawText(coord, cuLabel, 0, shift, shift, false);
painter.drawText(coord, cuLabel, 0, shift, shift, false);

if (getFlagPenumbraVisible())
{
Expand All @@ -2801,9 +2801,10 @@ void Satellites::drawCircles(StelCore* core)
penumbra.vertex.append(pos+point);
}

sPainter.setColor(getPenumbraColor(), 1.f);
sPainter.drawStelVertexArray(penumbra, false);
painter.setColor(getPenumbraColor(), 1.f);
painter.drawStelVertexArray(penumbra, false);
}
painter.setProjector(saveProj);
}

bool Satellites::checkJsonFileFormat()
Expand Down
2 changes: 1 addition & 1 deletion plugins/Satellites/src/Satellites.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ private slots:

private:
//! Drawing the circles of Earth's umbra and penumbra
void drawCircles(StelCore* core);
void drawCircles(StelCore* core, StelPainter& painter);
//! Add to the current collection the satellite described by the data.
//! @warning Use only in other methods! Does not update satelliteListModel!
//! @todo This probably could be done easier if Satellite had a constructor
Expand Down

0 comments on commit b9ceeb5

Please sign in to comment.