void TimelineAbstractRenderer::setNotes(TimelineNotesModel *notes)
{
    Q_D(TimelineAbstractRenderer);
    if (d->notes == notes)
        return;

    if (d->notes) {
        disconnect(d->notes, &TimelineNotesModel::changed,
                   this, &TimelineAbstractRenderer::setNotesDirty);
        disconnect(d->notes, &QObject::destroyed, this, nullptr);
    }

    d->notes = notes;
    if (d->notes) {
        connect(d->notes, &TimelineNotesModel::changed,
                this, &TimelineAbstractRenderer::setNotesDirty);
        connect(d->notes, &QObject::destroyed, this, [this, d]() {
            // Weak pointers are supposed to be notified before the destroyed() signal is sent.
            Q_ASSERT(d->notes.isNull());
            setNotesDirty();
            emit notesChanged(d->notes);
        });
    }

    setNotesDirty();
    emit notesChanged(d->notes);
}
void TimelineAbstractRenderer::setNotes(TimelineNotesModel *notes)
{
    Q_D(TimelineAbstractRenderer);
    if (d->notes == notes)
        return;

    if (d->notes)
        disconnect(d->notes, &TimelineNotesModel::changed,
                   this, &TimelineAbstractRenderer::setNotesDirty);

    d->notes = notes;
    if (d->notes)
        connect(d->notes, &TimelineNotesModel::changed,
                this, &TimelineAbstractRenderer::setNotesDirty);

    setNotesDirty();
    emit notesChanged(d->notes);
}