Skip to content

ReadOnlyPart: don't emit urlChanged() from destructor

Elvis Angelaccio requested to merge work/fix-crash-after-delete-with-qt6 into master

This causes a crash with Qt6 if a derived Part connects to the urlChanged() signal, like this:

    connect(this, &KParts::ReadOnlyPart::urlChanged, this, &MyPart::doSomethingWithUrl);

The crash is caused by an explicit assert added by this commit: https://code.qt.io/cgit/qt/qtbase.git/commit/?id=0e72a846d379ba02ff80ecac2526640a05b872b6

A unit test is added to reproduce the crash after adding such connection to the PartTest class.

To fix the crash we simply avoid to emit the urlChanged() signal from the ReadOnlyPart destructor.

Merge request reports