Skip to content
  • Friedrich W. H. Kossebau's avatar
    Fix KTextEditor::MainWindow to outlive the KTextEditor::View objects · 1641d714
    Friedrich W. H. Kossebau authored
    Summary:
    The KTextEditor::MainWindow API requires that the MainWindow wrapper
    object passed to the created KTextEditor::View objects "stays valid
    for the complete lifetime of the view."
    
    The old code had Shell::MainWindow own the MainWindow wrapper
    object as child object, thus deleting as part of its own destruction.
    Though any KTextEditor::View objects still alive are being deleted
    with deleteLater(), so only destructed on the next QEvent::DeferredDelete
    handling. And they still assume they can access the MainWindow wrapper
    during their shutdown as normal, e.g. to call "MainWindow::deleteViewBar".
    
    To get things into some proper order again, this patch adds a method
    KTextEditorIntegration::MainWindow::startDestroy(), which now is called
    in the destruction of Shell::MainWindow instead of instantly deleting the
    MainWindow wrapper object as normal child object. The method starts a
    delayed delete instead, to outlive any TextEditor::View objects
    being deleteLatered() inside the Core::self()->shutdown().
    
    KTextEditorIntegration::MainWindow also gets fixed to know about the
    state of being destroyed and in that case no longer do things on the
    former mainwindow object.
    
    The patch also moves the layout code for stacking the viewbars into a
    new special class Sublime::ViewBarContainer. That solves lifetime and
    ownership handling of the widget and the layout, and hides the
    implementation detail behind a simple API.
    While this makes viewBarContainer() no longer a simple plain widget
    to be customized by any caller, no other user is known which would need
    that.
    
    Reviewers: #kdevelop, croick, mwolff
    
    Subscribers: kdevelop-devel
    
    Tags: #kdevelop
    
    Differential Revision: https://phabricator.kde.org/D13905
    1641d714