Fix multiple memory leaks found with LeakSanitizer.

pull/33/head
whitequark 2016-08-07 19:33:42 +00:00
parent fbe2705ebe
commit 8bf55b3c62
5 changed files with 16 additions and 5 deletions

View File

@ -389,6 +389,8 @@ void GraphicsWindow::HitTestMakeSelection(Point2d mp) {
} }
} }
canvas.Clear();
if(!s.Equals(&hover)) { if(!s.Equals(&hover)) {
hover = s; hover = s;
PaintGraphics(); PaintGraphics();
@ -787,5 +789,6 @@ void GraphicsWindow::Paint() {
} }
canvas.EndFrame(); canvas.EndFrame();
canvas.Clear();
#endif #endif
} }

View File

@ -1187,19 +1187,21 @@ void Constraint::Draw(DrawAs how, Canvas *canvas) {
} }
Vector Constraint::GetLabelPos(const Camera &camera) { Vector Constraint::GetLabelPos(const Camera &camera) {
Vector p;
ObjectPicker canvas = {}; ObjectPicker canvas = {};
canvas.camera = camera; canvas.camera = camera;
Vector p;
DoLayout(DrawAs::DEFAULT, &canvas, &p, NULL); DoLayout(DrawAs::DEFAULT, &canvas, &p, NULL);
canvas.Clear();
return p; return p;
} }
void Constraint::GetReferencePoints(const Camera &camera, std::vector<Vector> *refs) { void Constraint::GetReferencePoints(const Camera &camera, std::vector<Vector> *refs) {
ObjectPicker canvas = {}; ObjectPicker canvas = {};
canvas.camera = camera; canvas.camera = camera;
DoLayout(DrawAs::DEFAULT, &canvas, NULL, refs); DoLayout(DrawAs::DEFAULT, &canvas, NULL, refs);
canvas.Clear();
} }
bool Constraint::IsStylable() const { bool Constraint::IsStylable() const {

View File

@ -126,14 +126,17 @@ void Entity::GetReferencePoints(std::vector<Vector> *refs) {
} }
int Entity::GetPositionOfPoint(const Camera &camera, Point2d p) { int Entity::GetPositionOfPoint(const Camera &camera, Point2d p) {
int position;
ObjectPicker canvas = {}; ObjectPicker canvas = {};
canvas.camera = camera; canvas.camera = camera;
canvas.point = p; canvas.point = p;
canvas.minDistance = 1e12; canvas.minDistance = 1e12;
Draw(DrawAs::DEFAULT, &canvas); Draw(DrawAs::DEFAULT, &canvas);
position = canvas.position;
canvas.Clear();
return canvas.position; return position;
} }
bool Entity::IsStylable() const { bool Entity::IsStylable() const {

View File

@ -220,6 +220,8 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool exp
for(Constraint &c : SK.constraint) { for(Constraint &c : SK.constraint) {
c.Draw(Constraint::DrawAs::DEFAULT, &canvas); c.Draw(Constraint::DrawAs::DEFAULT, &canvas);
} }
canvas.Clear();
} }
} }

View File

@ -858,6 +858,7 @@ void TextWindow::Paint() {
DrawOrHitTestColorPicker(&uiCanvas, PAINT, false, 0, 0); DrawOrHitTestColorPicker(&uiCanvas, PAINT, false, 0, 0);
canvas.EndFrame(); canvas.EndFrame();
canvas.Clear();
#endif #endif
} }