Skip to content
  • Akarsh Simha's avatar
    Fix crash in observing list whenever catalog configuration was changed. · f11601a3
    Akarsh Simha authored
    a.k.a. the "Wishlist-Killer" bug.
    
    A very frustrating crash would ensue whenever the catalog
    configuration options were changed (eg: adding a new custom catalog)
    and an object was added to the observing wishlist. Before a recent
    commit, the wishlist would be truncated causing much frustration to
    the user.
    
    The crash occurred because the SkyObjects are de-allocated and
    re-allocated by SkyMapComposite::reloadDeepSky() every time the
    catalog configuration objects have changed. Since the ObservingList
    maintained a QList<SkyObject *> pointers to these SkyObjects, we were
    often querying dangling pointers, leading to crashes. So addition of
    the object to the wishlist, although did trigger the bug, was not the
    root cause.
    
    This change fixes the bug (hopefully without inducing any
    others!). The changes are:
    
    1. Create a clone of the SkyObject in ObservingList
    
       This makes add / remove more complicated as they look-up the given
       object by name, but solves the crash because we have a local copy
       of the SkyObject even if the CatalogComponent's copy is deleted.
    
    2. Use QSharedPointer<SkyObject> instead of SkyObject *
    
       This makes sure that we don't re-create the same object for session
       plan / wish list. Besides, it is much more cleaner, and takes care
       of deleting itself etc.
    
    Extensive testing is appreciated.
    
    And once again, happy 20th Birthday KDE!
    
    BUG: 345348
    CCMAIL: kstars-devel@kde.org
    f11601a3