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.
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.
May 31, 2008 at 7:58 pm
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…
June 4, 2008 at 6:14 am
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.
June 7, 2008 at 10:58 am
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
http://doc.trolltech.com/4.4/qatomicint.html
June 8, 2008 at 8:52 pm
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.