[Digikam-devel] [Bug 129610] New: digikam: unsupported initialization of CameraList object

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Digikam-devel] [Bug 129610] New: digikam: unsupported initialization of CameraList object

Bugzilla from ach@mpe.mpg.de
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=129610         
           Summary: digikam: unsupported initialization of CameraList object
           Product: digikam
           Version: unspecified
          Platform: unspecified
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: digikam-devel kde org
        ReportedBy: ach mpe mpg de


Version:           0.8.2-rc1 (using KDE 3.5.2, Kubuntu Package 4:3.5.2-0ubuntu18 dapper)
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.15-25-686

While checking the diff between 2.1.6 and 2.2 headers I stumpled
over this:

+/* Usage pattern for CameraList for users external of
+ * libgphoto2, such as libgphoto2 frontends:
+ *
+ *    CameraList *list;
+ *    gp_list_new (&list);
+ *    init_list_somehow (list);
+ *    for (i=0; i < gp_list_count(list); i++) {
+ *        char *name, *value;
+ *        gp_list_get_name (list, i, &name);
+ *        gp_list_get_name (list, i, &value);
+ *        do_something_with (name, value);
+ *    }
+ *    gp_list_free (list);
+ *
+ * Please do NOT directly instantiate a CameraList object like this:
+ *               CameraList foo;     // DO NOT DO THIS
+ * Please do NOT directly access the structure members like this:
+ *               list->entry[i].name // DO NOT DO THIS
+ */

Grep on sources in trunk:

$ grep -n CameraList cameragui/*
cameragui/gpcamera.cpp:295:    CameraList *clist;
cameragui/gpcamera.cpp:337:    CameraList *clist;
cameragui/gpcamera.cpp:382:    CameraList *clist;
cameragui/gpcamera.cpp:852:    CameraList camList;
                               ^^^^^^^^^^^^^^^^^^  that's a DO NOT DO THIS

Last but not least:

$ grep -n clist- cameragui/* | echo good
good

;)

Achim
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Digikam-devel] [Bug 129610] digikam: unsupported initialization of CameraList object

Gilles Caulier
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=129610         




------- Additional Comments From caulier.gilles free fr  2006-06-21 23:07 -------
SVN commit 553726 by cgilles:

digikam from trunk : fix initialization of CameraList object
CCBUGS: 129610


 M  +25 -18    gpcamera.cpp  
 M  +1 -2      gpcamera.h  


--- trunk/extragear/graphics/digikam/utilities/cameragui/gpcamera.cpp #553725:553726
 @ -41,6 +41,10  @
 #include <qdom.h>
 #include <qfile.h>
 
+// KDE includes.
+
+#include <kdebug.h>
+
 // Local includes.
 
 #include "gpcamera.h"
 @ -782,7 +786,7  @
     if ( count < 0)
     {
         gp_context_unref( context );
-        qWarning("failed to get list of cameras");
+        kdDebug() << "failed to get list of cameras!" << endl;
         return;
     }
     else
 @ -849,39 +853,42  @
 
 int GPCamera::autoDetect(QString& model, QString& port)
 {
-    CameraList camList;
+    CameraList          *camList;
     CameraAbilitiesList *abilList;
-    GPPortInfoList *infoList;
-    const char *camModel_, *camPort_;
-    GPContext *context;
+    GPPortInfoList      *infoList;
+    const char          *camModel_, *camPort_;
+    GPContext           *context;
 
     context = gp_context_new();
+    gp_list_new(&camList);
 
-    gp_abilities_list_new (&abilList);
-    gp_abilities_list_load (abilList, context);
-    gp_port_info_list_new (&infoList);
-    gp_port_info_list_load (infoList);
-    gp_abilities_list_detect (abilList, infoList, &camList, context);
-    gp_abilities_list_free (abilList);
-    gp_port_info_list_free (infoList);
+    gp_abilities_list_new(&abilList);
+    gp_abilities_list_load(abilList, context);
+    gp_port_info_list_new(&infoList);
+    gp_port_info_list_load(infoList);
+    gp_abilities_list_detect(abilList, infoList, camList, context);
+    gp_abilities_list_free(abilList);
+    gp_port_info_list_free(infoList);
 
-    gp_context_unref( context );
+    gp_context_unref(context);
 
-    int count = gp_list_count (&camList);
+    int count = gp_list_count(camList);
 
-    if (count<=0)
+    if (count <= 0)
     {
+        gp_list_free(camList);
         return -1;
     }
 
-    for (int i = 0; i < count; i++)
+    for (int i = 0 ; i < count ; i++)
     {
-        gp_list_get_name  (&camList, i, &camModel_);
-        gp_list_get_value (&camList, i, &camPort_);
+        gp_list_get_name (camList, i, &camModel_);
+        gp_list_get_value(camList, i, &camPort_);
     }
 
     model = camModel_;
     port  = camPort_;
+    gp_list_free(camList);
 
     return 0;
 }
--- trunk/extragear/graphics/digikam/utilities/cameragui/gpcamera.h #553725:553726
 @ -93,8 +93,7  @
     
     static void getSupportedCameras(int& count, QStringList& clist);
     static void getSupportedPorts(QStringList& plist);
-    static void getCameraSupportedPorts(const QString& model,
-                                        QStringList& plist);
+    static void getCameraSupportedPorts(const QString& model, QStringList& plist);
     static int  autoDetect(QString& model, QString& port);
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Digikam-devel] [Bug 129610] digikam: unsupported initialization of CameraList object

Gilles Caulier
In reply to this post by Bugzilla from ach@mpe.mpg.de
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=129610         




------- Additional Comments From caulier.gilles free fr  2006-06-21 23:31 -------
SVN commit 553732 by cgilles:

digikam from stable : fix initialization of CameraList object
CCBUGS: 129610


 M  +57 -36    gpcamera.cpp  


--- branches/stable/extragear/graphics/digikam/utilities/cameragui/gpcamera.cpp #553731:553732
 @ -18,40 +18,57  @
  *
  * ============================================================ */
 
+// C Ansi includes.
+
+extern "C"
+{
+#include <stdio.h>
+#include <gphoto2.h>
+}
+
+// C++ includes.
+
+#include <iostream>
+
+// Qt includes.
+
 #include <qstring.h>
 #include <qstringlist.h>
 #include <qimage.h>
 #include <qdom.h>
 #include <qfile.h>
 
-#include <iostream>
+// KDE includes.
 
-extern "C" {
-#include <stdio.h>
-#include <gphoto2.h>
-}
+#include <kdebug.h>
 
+// Local includes.
+
 #include "gpcamera.h"
 
 class GPCameraPrivate
 {
 public:
 
-    Camera *camera;
-    CameraAbilities cameraAbilities;
+    GPCameraPrivate()
+    {
+        camera = 0;
+    }
 
-    QString model;
-    QString port;
-    QString globalPath;
-
-    bool cameraInitialized;
+    bool             cameraInitialized;
     
-    bool thumbnailSupport;
-    bool deleteSupport;
-    bool uploadSupport;
-    bool mkDirSupport;
-    bool delDirSupport;
+    bool             thumbnailSupport;
+    bool             deleteSupport;
+    bool             uploadSupport;
+    bool             mkDirSupport;
+    bool             delDirSupport;
     
+    QString          model;
+    QString          port;
+    QString          globalPath;
+
+    Camera          *camera;
+    CameraAbilities  cameraAbilities;
 };
 
 class GPStatus
 @ -802,38 +819,42  @
 
 int GPCamera::autoDetect(QString& model, QString& port)
 {
-    CameraList camList;
+    CameraList          *camList;
     CameraAbilitiesList *abilList;
-    GPPortInfoList *infoList;
-    const char *camModel_, *camPort_;
-    GPContext *context;
+    GPPortInfoList      *infoList;
+    const char          *camModel_, *camPort_;
+    GPContext           *context;
 
-    context = gp_context_new ();
+    context = gp_context_new();
+    gp_list_new(&camList);
 
-    gp_abilities_list_new (&abilList);
-    gp_abilities_list_load (abilList, context);
-    gp_port_info_list_new (&infoList);
-    gp_port_info_list_load (infoList);
-    gp_abilities_list_detect (abilList, infoList,
-                              &camList, context);
-    gp_abilities_list_free (abilList);
-    gp_port_info_list_free (infoList);
+    gp_abilities_list_new(&abilList);
+    gp_abilities_list_load(abilList, context);
+    gp_port_info_list_new(&infoList);
+    gp_port_info_list_load(infoList);
+    gp_abilities_list_detect(abilList, infoList, camList, context);
+    gp_abilities_list_free(abilList);
+    gp_port_info_list_free(infoList);
 
-    gp_context_unref( context );
+    gp_context_unref(context);
 
-    int count = gp_list_count (&camList);
+    int count = gp_list_count(camList);
 
-    if (count<=0) {
+    if (count <= 0)
+    {
+        gp_list_free(camList);
         return -1;
     }
 
-    for (int i = 0; i < count; i++) {
-        gp_list_get_name  (&camList, i, &camModel_);
-        gp_list_get_value (&camList, i, &camPort_);
+    for (int i = 0 ; i < count ; i++)
+    {
+        gp_list_get_name (camList, i, &camModel_);
+        gp_list_get_value(camList, i, &camPort_);
     }
 
     model = camModel_;
     port  = camPort_;
+    gp_list_free(camList);
 
     return 0;
 }
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Digikam-devel] [Bug 129610] digikam: unsupported initialization of CameraList object

Gilles Caulier
In reply to this post by Bugzilla from ach@mpe.mpg.de
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=129610         
caulier.gilles free fr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From caulier.gilles free fr  2006-06-21 23:54 -------
Fixed in svn. Closed

Gilles
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel