Disable trace mode in KmPlot before deleting tracing curve from the plot
ClosedPublic

Authored by yurchor on Oct 19 2018, 5:18 PM.

Details

Summary

Deleting curves without disabling tracing first crashes KmPlot.

BUG: 325627

Test Plan
  1. Add a Cartesian curve on the plot ( e.g., f(x) = x^3).
  2. Left-click on it to start tracing.
  3. Push the "Delete" button under the "Functions" list.
  4. KmPlot should not crash anymore, the curve should disappear with the corresponding labels on the status bar.

Diff Detail

Repository
R334 KmPlot
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
yurchor created this revision.Oct 19 2018, 5:18 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptOct 19 2018, 5:18 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
yurchor requested review of this revision.Oct 19 2018, 5:18 PM
aacid added a subscriber: aacid.Oct 19 2018, 8:54 PM
aacid added inline comments.
kmplot/parser.cpp
660 ↗(On Diff #43941)

I've no idea about kmplot so excuse me if what i say makes no sense :D

My guess is here you would actually want to compare m_currentPlot.functionId with something from "Function *item"?

I mean if you're removing a function that is not the plotted one does the view care?

yurchor marked an inline comment as done.Oct 20 2018, 6:03 AM
yurchor added inline comments.
kmplot/parser.cpp
660 ↗(On Diff #43941)

Yes. That would be even better. Thanks.

yurchor updated this revision to Diff 43960.Oct 20 2018, 6:04 AM
yurchor marked an inline comment as done.

Disable tracing only when it's really needed.

yurchor updated this revision to Diff 43965.Oct 20 2018, 11:20 AM

Save some distant calls.

Can somebody review this minor change? Thanks in advance for your time.

I think it would make more sense if the logic of the code was on View itself and not parser, i.e. parser doesn't care about views, but views care about function it's viewing.

We already have the

emit functionRemoved( id );

in that function so doing something like

connect(XParser::self(), &Parser::functionRemoved, this, &View::functionRemoved)

and then make the functionRemoved function do something similar to the new code you added.

At the end "it's the same", but i think it makes more sense from an architectural point of view.

What do you think?

I think it would make more sense if the logic of the code was on View itself and not parser, i.e. parser doesn't care about views, but views care about function it's viewing.

We already have the

emit functionRemoved( id );

in that function so doing something like

connect(XParser::self(), &Parser::functionRemoved, this, &View::functionRemoved)

and then make the functionRemoved function do something similar to the new code you added.

At the end "it's the same", but i think it makes more sense from an architectural point of view.

What do you think?

I think that

  1. I cannot find the place for this connect. There is already
connect(XParser::self(), &XParser::functionRemoved, this, &FunctionEditor::functionsChanged);

in functioneditor.cpp.

  1. If it will be placed in View then View should have to be acknowledged of what to remove and we again should add some public variables to do so even if we do not use them in the case when nothing's going to be removed.

Any ideas? Can we avoid complete rewrite of KmPlot to fix this tiny bug?

yurchor updated this revision to Diff 44699.Nov 2 2018, 12:27 PM

Trying to keep the architecture.

yurchor updated this revision to Diff 44701.Nov 2 2018, 12:30 PM

Remove unneeded type conversion.

Please disregard the above questions. It takes some time to understand the things as they should be. And thanks for the suggestions.

aacid added inline comments.Nov 2 2018, 10:06 PM
kmplot/functioneditor.cpp
144 ↗(On Diff #44701)

Can you try moving this to View() constructor and see if it works?

obviously replacing View::self with this (but you knew that)

If that works i think it makes more sense there than in functioneditor.

It's the View saying "I'm interested in signals from when the parser" than the functioneditor, i think that the view is interested in signals from the parser.

Other than that, thanks for accepting my reviews that sometimes are a bit annoying :)

yurchor updated this revision to Diff 44753.Nov 3 2018, 7:47 AM

Move connect() to the View constructor. Tested to work.

aacid accepted this revision.Nov 3 2018, 11:32 AM

Thanks for putting up with my comments :)

This revision is now accepted and ready to land.Nov 3 2018, 11:32 AM
This revision was automatically updated to reflect the committed changes.