Fixing bad memory management in the Conjunctions Tool – All my fault! 😀
Instance management in KSMoon
Akarsh Simha, Gopala Krishna, and arunchaganty are discussing. Toggle Comments
Regd. the 2nd bug fix, doesn’t KDE have a mechanism for taking care of object references? Glib has g_object_ref and g_object_unref, for the same purpose. Also, without looking at the source, the ks_moon is a static *class* variable, does this mean KSMoon is a singleton class? (just out of curiousity), or possibly just the star data is…
I don’t think the KDE API has such a mechanism. Actually, it wouldn’t be as important here, because we are using C++ and not C.
KSMoon is not a singleton class, but has a few static members in it, that describe coeffecients of various terms in a sinusoidal series used to compute the moon’s position (I don’t know the details).
Interestingly, this concept struck me because of my minor experience with GLib. g_object_ref and g_object_unref was what gave me the idea of adding a reference count.
Though KDE doesn’t have the reference counting mechanism directly, its inherited from qt4.
One of the mechanism is using QSharedData and QSharedDataPointer classes, although the classes primarily are for implicit sharing.
Secondly, qt4.4 has uncovered its atomic api a bit, which helps in safe reference counting across threads. Here is a link
Ahh… while I think that QSharedDataPointer etc might help here, I think they are too much of an overkill for something as simple as we required here, as you said. Thanks for the information.
← Astronomers actually use KStars to control their observatories!
KStars loads 41560 stars in 225ms!!! →
Blog at WordPress.com.