Skip to content
  • Igor Kushnir's avatar
    Kill ParseProjectJob before closing its project · 0b037a8c
    Igor Kushnir authored
    Remove the now redundant deleting of the ParseProjectJob when its
    project is destroyed. ParseProjectJob objects are created in
    ProjectController::reparseProject(), which is called when the project is
    already fully open. So the project is guaranteed to be closed before it
    is destroyed.
    
    A Project is destroyed via deleteLater() after it is closed, so if the
    event loop is busy at the time, &IProject::destroyed can be emitted much
    later than IProjectController::projectClosing(). With this commit
    ParseProjectJob is killed earlier than it was destroyed without the
    commit.
    
    Early-return from ParseProjectJob::queueFilesToParse() not only when the
    job has been destroyed, but when it has been killed too. The earlier
    return not just avoids unnecessary work, but is essential during the
    application shutdown: prevents a crash by not accessing IndexedString
    after DUChain::shutdown(). Note that KJob::kill() calls deleteLater(),
    so a job can be destroyed a long time after it is killed if the event
    loop is busy, as it is at shutdown. ParseProjectJob is killed early in
    the shutdown process from RunController::cleanup() - before
    ProjectController::cleanup(), which would kill it otherwise, and
    (importantly to prevent the crash) before DUChain::shutdown().
    
    Remove the shuttingDown() check from ParseProjectJob::start(), because
    this member function doesn't access globals on its own. The appropriate
    safety checks are now performed in the scheduled
    ParseProjectJob::queueFilesToParse().
    
    Don't call deleteLater() in ParseProjectJob::doKill() just before
    returning true: rely on auto-delete KJob base class to call it.
    
    BUG: 427387
    FIXED-IN: 5.6.1
    0b037a8c