Refactor canvas event handling
ClosedPublic

Authored by anthonyfieroni on May 8 2020, 5:35 PM.

Details

Summary

CCBUG: 421083

It looks like there is no need to have list of root views (since it has only one) it should be deleted when there is a new central widget.

Test Plan

No crash any more.

Diff Detail

Repository
R8 Calligra
Lint
Lint Skipped
Unit
Unit Tests Skipped
anthonyfieroni created this revision.May 8 2020, 5:35 PM
Restricted Application added a project: Calligra: 3.0. · View Herald TranscriptMay 8 2020, 5:35 PM
Restricted Application added a subscriber: Calligra-Devel-list. · View Herald Transcript
anthonyfieroni requested review of this revision.May 8 2020, 5:35 PM

Add more context

Hmmm, it seems to me you are creating a leak in your lines 544, 545? (Have not tested, I might be wrong)

Afaics the problem is that a focus event is issued that accesses the view after death.
Possibly a deleteLater() would do it, but I tried with setting paret to nullptr:

while(!oldRootViews.isEmpty()) {
    KoView *v = oldRootViews.takeFirst();
    v->setParent(nullptr);
    delete v;
}

(Also in KoMainWindow dtor to be consistent.)

d->rootPart->createView(doc, this); Creates the view which parent is main window.

`d->rootPart->createView(doc, this);` Creates the view which parent is main window.

Ahh, yes, but then...
Why will it not crash if a new document is set so that d->rootView != 0 ?

We should call removeEventFilter or found exactly why signal is emitted in destructor.

anthonyfieroni retitled this revision from Refactor MainWindow view to Refactor canvas event handling.May 12 2020, 10:26 AM
anthonyfieroni updated this revision to Diff 82646.EditedMay 12 2020, 10:29 AM

@danders i saw your patch on my email. d->viewportWidget->canvas()->removeEventFilter(this); fixes the issue but i still prefer all of refactoring code. Please test on all components does not have regressions.

danders added a comment.EditedMay 13 2020, 7:15 AM

This seems to work fine, I also tested with only pageapp/flake changes.
Imho I would prefer to separate the pageapp/flake and KoMainWindow changes into separate commits,
The pageapp/flake changes should go into 3.2 branch followed by a swift release.
I don't think the KoMainWindow changes should go into the branch as it only removes unused functionallity.
I'm a bit in two minds if it should go in at all actually, so I'll leave it you or maybe somebody else has an opinion.

Seems fine, i'll push pageapp/flake changes as part of this review in 3.2 branch and master, refactoring main window in separate commit master only.

This revision was not accepted when it landed; it landed in state Needs Review.May 13 2020, 8:51 AM
This revision was automatically updated to reflect the committed changes.
leinir added a subscriber: leinir.May 13 2020, 9:46 AM

Incidentally, while this was committed before i could test it, i can confirm that it works fine with Calligra Gemini

Thank you, i should wait ship it, but just got Dag comment as it is.