Update of /cvsroot/ufraw/ufraw
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5568

Modified Files:
        ufobject.cc ufraw-batch.c ufraw.c ufraw_conf.c 
        ufraw_lensfun.cc 
Log Message:
Add an option to destroy lensdb and use it to find and fix some valgrind errors.


Index: ufraw_lensfun.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_lensfun.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ufraw_lensfun.cc    21 Feb 2010 10:03:55 -0000      1.1
+++ ufraw_lensfun.cc    24 Feb 2010 00:24:15 -0000      1.2
@@ -23,9 +23,19 @@
 namespace UFRaw {
 
 class Lensfun : public UFGroup {
+private:
+    static lfDatabase *GlobalLensDB;
 public:
     Lensfun();
+#if 0 // Can be useful for valgrind --leak-check=full
+    ~Lensfun() {
+       if (GlobalLensDB != NULL)
+           lf_db_destroy(GlobalLensDB);
+       GlobalLensDB = NULL;
+    }
+#endif
     void Interpolate(const lfLens *lens);
+    void Init();
 };
 
 extern "C" { UFName ufModel = "Model"; }
@@ -271,21 +281,16 @@
     static_cast<Distortion &>((*this)[ufDistortion]).Interpolate(lens);
 }
 
-extern "C" {
-void ufraw_lensfun_interpolate(UFObject *lensfun, const lfLens *lens) {
-    Lensfun &Lensfun = dynamic_cast<UFRaw::Lensfun &>(*lensfun);
-    Lensfun.Interpolate(lens);
-}
+lfDatabase *Lensfun::GlobalLensDB = NULL;
 
-void ufraw_lensfun_init(ufraw_data *uf)
-{
+void Lensfun::Init() {
     /* Load lens database only once */
-    static lfDatabase *lensdb = NULL;
-    if (lensdb == NULL) {
-       lensdb = lf_db_new();
-       lf_db_load(lensdb);
+    if (GlobalLensDB == NULL) {
+       GlobalLensDB = lfDatabase::Create();
+       GlobalLensDB->Load();
     }
-    uf->conf->lensdb = lensdb;
+    ufraw_data *uf = ufraw_image_get_data(this);
+    uf->conf->lensdb = GlobalLensDB;
 
     /* Create a default lens & camera */
     uf->conf->lens = lf_lens_new();
@@ -309,26 +314,36 @@
            lf_free(lenses);
        }
     }
-    UFGroup &Image = *uf->conf->ufobject;
-    UFGroup &Lensfun = Image[ufLensfun];
     if (uf->conf->lensfunMode == lensfun_default) {
        if (uf->LoadingID) {
-           Lensfun[ufTCA].Event(uf_value_changed);
-           Lensfun[ufVignetting].Event(uf_value_changed);
-           Lensfun[ufDistortion].Event(uf_value_changed);
+           (*this)[ufTCA].Event(uf_value_changed);
+           (*this)[ufVignetting].Event(uf_value_changed);
+           (*this)[ufDistortion].Event(uf_value_changed);
            return;
        }
        uf->conf->lensfunMode = lensfun_auto;
     }
     if (uf->conf->lensfunMode == lensfun_none) {
-       Lensfun[ufTCA].Reset();
-       Lensfun[ufVignetting].Reset();
-       Lensfun[ufDistortion].Reset();
+       (*this)[ufTCA].Reset();
+       (*this)[ufVignetting].Reset();
+       (*this)[ufDistortion].Reset();
     } else {
-       static_cast<UFRaw::Lensfun &>(Lensfun).Interpolate(uf->conf->lens);
+       Interpolate(uf->conf->lens);
     }
 }
 
+extern "C" {
+void ufraw_lensfun_interpolate(UFObject *lensfun, const lfLens *lens) {
+    Lensfun &Lensfun = dynamic_cast<UFRaw::Lensfun &>(*lensfun);
+    Lensfun.Interpolate(lens);
+}
+
+void ufraw_lensfun_init(ufraw_data *uf) {
+    UFGroup &Image = *uf->conf->ufobject;
+    UFRaw::Lensfun &Lensfun =  static_cast<UFRaw::Lensfun &>(Image[ufLensfun]);
+    Lensfun.Init();
+}
+
 }
 
 } // namespace UFRaw

Index: ufraw_conf.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_conf.c,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- ufraw_conf.c        23 Feb 2010 19:36:43 -0000      1.161
+++ ufraw_conf.c        24 Feb 2010 00:24:15 -0000      1.162
@@ -178,6 +178,7 @@
 typedef struct {
     conf_data *conf;
     UFObject *group;
+    GQuark ufrawQuark;
 } parse_data;
 
 static void conf_parse_start(GMarkupParseContext *context,
@@ -186,11 +187,8 @@
 {
     parse_data *data = (parse_data *)user;
     conf_data *c = data->conf;
-
     int int_value;
-    GQuark ufrawQuark = g_quark_from_static_string("UFRaw");
-
-    context = context;
+    (void)context;
 
     int i;
     for (i = 0; names[i] != NULL; i++) {
@@ -218,7 +216,7 @@
            }
            data->group = ufgroup_element(data->group, values[i]);
            if (strcmp(ufobject_name(data->group), element) != 0)
-               g_set_error(error, ufrawQuark, UFRAW_ERROR,
+               g_set_error(error, data->ufrawQuark, UFRAW_ERROR,
                        "Expecting '%s' XML element and not '%s' XML element",
                        ufobject_name(data->group), element);
            return;
@@ -248,7 +246,7 @@
                c->version = int_value;
            }
            if (int_value!=c->version)
-               g_set_error(error, ufrawQuark, UFRAW_RC_VERSION,
+               g_set_error(error, data->ufrawQuark, UFRAW_RC_VERSION,
                    _("UFRaw version in .ufrawrc is not supported"));
        }
        if (!strcmp(*names,"Current") && int_value!=0) {
@@ -794,6 +792,7 @@
        user_data.group = c->ufobject;
     else
        user_data.group = ufgroup_element(c->ufobject, ufRawImage);
+    user_data.ufrawQuark = g_quark_from_static_string("UFRaw");
     context = g_markup_parse_context_new(&parser, 0, &user_data, NULL);
     line[max_path-1] = '\0';
     char *dummy = fgets(line, max_path-1, in);
@@ -807,7 +806,7 @@
            fclose(in);
            // We could if needed check explicitly for a version mismatch error
            //GQuark ufrawQuark = g_quark_from_static_string("UFRaw");
-           //if (g_error_matches(err, ufrawQuark, UFRAW_RC_VERSION))
+           //if (g_error_matches(err, data->ufrawQuark, UFRAW_RC_VERSION))
            g_error_free(err);
            uf_reset_locale(locale);
            return UFRAW_ERROR;

Index: ufobject.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufobject.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ufobject.cc 22 Feb 2010 23:27:20 -0000      1.4
+++ ufobject.cc 24 Feb 2010 00:24:15 -0000      1.5
@@ -755,7 +755,7 @@
 
 UFArray::UFArray(UFName name, const char *defaultIndex) :
        UFGroup(name, defaultIndex) {
-    defaultIndex = g_strdup(defaultIndex);
+    ufgroup->DefaultIndex = g_strdup(defaultIndex);
 }
 
 std::string UFArray::XML(const char *indent) const {

Index: ufraw-batch.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw-batch.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- ufraw-batch.c       21 Feb 2010 10:03:55 -0000      1.35
+++ ufraw-batch.c       24 Feb 2010 00:24:15 -0000      1.36
@@ -102,6 +102,7 @@
        g_free(uf);
     }
 //    ufraw_close(cmd.darkframe);
+    ufobject_delete(cmd.ufobject);
     ufobject_delete(rc.ufobject);
     exit(exitCode);
 }

Index: ufraw.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- ufraw.c     21 Feb 2010 10:03:55 -0000      1.56
+++ ufraw.c     24 Feb 2010 00:24:15 -0000      1.57
@@ -119,6 +119,7 @@
     if (dummyWindow!=NULL) gtk_widget_destroy(dummyWindow);
 
 //    ufraw_close(cmd.darkframe);
+    ufobject_delete(cmd.ufobject);
     ufobject_delete(rc.ufobject);
     exit(exitCode);
 }


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
ufraw-cvs mailing list
ufraw-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ufraw-cvs

Reply via email to