tasn pushed a commit to branch master.

http://git.enlightenment.org/bindings/cxx/eflxx.git/commit/?id=b4e95658b90ee817268b7a03cbc530d04b36be27

commit b4e95658b90ee817268b7a03cbc530d04b36be27
Author: Andreas Volz <[email protected]>
Date:   Thu May 27 20:30:39 2010 +0000

    Fixed the crash at list element selection
    
    SVN revision: 49238
---
 elementaryxx/include/elementaryxx/GenList.h        |  4 ++++
 .../include/elementaryxx/GenListDataModel.h        | 14 ++++++-------
 elementaryxx/src/GenList.cpp                       | 24 +++++++++++++++++-----
 elementaryxx/src/GenListDataModel.cpp              |  9 ++++++--
 elementaryxx/src/Makefile.am                       |  4 +++-
 5 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/elementaryxx/include/elementaryxx/GenList.h 
b/elementaryxx/include/elementaryxx/GenList.h
index 021931c..c75d5dd 100644
--- a/elementaryxx/include/elementaryxx/GenList.h
+++ b/elementaryxx/include/elementaryxx/GenList.h
@@ -332,8 +332,12 @@ private:
   ~GenList (); // forbid direct delete -> use Object::destroy()
   
   static void gl_sel (void *data, Evas_Object *obj, void *event_info);
+
+  void glSelected (Evasxx::Object &eo, void *event_info);
   
   GenListDataModel *mModel;
+
+  std::list <GenListColumnSelector*> mInternalSelList;
 };
 
 #if 0
diff --git a/elementaryxx/include/elementaryxx/GenListDataModel.h 
b/elementaryxx/include/elementaryxx/GenListDataModel.h
index 8cc3221..b420934 100644
--- a/elementaryxx/include/elementaryxx/GenListDataModel.h
+++ b/elementaryxx/include/elementaryxx/GenListDataModel.h
@@ -22,16 +22,15 @@ class GenListDataModel
 public:
   friend class GenList;
   
-  GenListDataModel ();
-  
-  // TODO: implement these 4 functions pure virtual?
-  
+  GenListDataModel (const std::string &style);
+
+  // TODO: empty default implementation for these 4 as virtuals leads into 
nullpointer exception. why?
   std::string getLabel (GenListColumnConstructor *construction, Evasxx::Object 
&obj, const std::string &part) const;
-  
+
   Elmxx::Object *getIcon (GenListColumnConstructor *construction, 
Evasxx::Object &obj, const std::string &part);
-  
+
   bool getState (GenListColumnConstructor *construction, Evasxx::Object &obj, 
const std::string &part);
-  
+
   void del (GenListColumnConstructor *construction, Evasxx::Object &obj);
 
 private:
@@ -41,6 +40,7 @@ private:
   static void gl_del (const void *data, Evas_Object *obj);
   
   Elm_Genlist_Item_Class mGLIC;
+  std::string mStyle;
 };
 
 } // end namespace Elmxx
diff --git a/elementaryxx/src/GenList.cpp b/elementaryxx/src/GenList.cpp
index fa18b23..7e7adca 100644
--- a/elementaryxx/src/GenList.cpp
+++ b/elementaryxx/src/GenList.cpp
@@ -7,6 +7,7 @@
 #include "../include/elementaryxx/GenListItem.h"
 #include "../include/elementaryxx/GenListColumnConstructor.h"
 #include "../include/elementaryxx/GenListColumnSelector.h"
+#include "localUtil.h"
 
 /* STD */
 #include <cassert>
@@ -22,7 +23,10 @@ GenList::GenList (Evasxx::Object &parent)
   elmInit ();
 }
 
-GenList::~GenList () {}
+GenList::~GenList ()
+{
+  delete_stl_container <std::list <GenListColumnSelector*>, 
GenListColumnSelector*> (mInternalSelList);
+}
 
 GenList *GenList::factory (Evasxx::Object &parent)
 {
@@ -125,9 +129,19 @@ void GenList::setDataModel (GenListDataModel &model)
 void GenList::gl_sel (void *data, Evas_Object *obj, void *event_info)
 {
   GenListColumnSelector *selection = (GenListColumnSelector*) data;
+  assert (selection);
   GenList *gl = selection->mGenList;
+  assert (gl);
   Evasxx::Object *eo = Evasxx::Object::objectLink (obj);
-  gl->signalSelect.emit (*eo, event_info);
+  assert (eo);
+  gl->glSelected (*eo, event_info);
+}
+
+void GenList::glSelected (Evasxx::Object &eo, void *event_info)
+{
+  cout << "GenList::glSelected" << endl;
+  // FIXME: this call seems to segfault after the list is constructed after 2 
or 3 seconds
+  //signalSelect.emit (eo, event_info);
 }
 
 /* operations to add items */
@@ -150,7 +164,7 @@ void GenList::append (GenListColumnConstructor 
*construction, GenListItem *paren
   
   if (!selection)
   {
-    // create internal construction object if construction==NULL was given and 
delete if after adding
+    // create internal construction object if selection==NULL was given and 
delete if after adding
     // this is needed to provide the user an easy API to add type save data to 
item append callbacks
     internalSelection = true;
     selection = new GenListColumnSelector ();  
@@ -172,8 +186,8 @@ void GenList::append (GenListColumnConstructor 
*construction, GenListItem *paren
   }
   if (internalSelection)
   {
-    delete selection;
-  } 
+      mInternalSelList.push_back (selection);
+  }
 }
 
 } // end namespace Elmxx
diff --git a/elementaryxx/src/GenListDataModel.cpp 
b/elementaryxx/src/GenListDataModel.cpp
index eee00a5..d2aed39 100644
--- a/elementaryxx/src/GenListDataModel.cpp
+++ b/elementaryxx/src/GenListDataModel.cpp
@@ -11,9 +11,11 @@ using namespace std;
 
 namespace Elmxx {
 
-GenListDataModel::GenListDataModel ()
+GenListDataModel::GenListDataModel (const std::string &style) :
+  mStyle (style)
 {
-  mGLIC.item_style     = "default";
+  cout << "creating GenListDataModel with style = " << mStyle << endl;
+  mGLIC.item_style     = mStyle.c_str ();
   mGLIC.func.label_get = GenListDataModel::gl_label_get;
   mGLIC.func.icon_get  = GenListDataModel::gl_icon_get;
   mGLIC.func.state_get = GenListDataModel::gl_state_get;
@@ -61,6 +63,9 @@ char *GenListDataModel::gl_label_get (const void *data, 
Evas_Object *obj, const
   Evasxx::Object *objWrap = Evasxx::Object::objectLink (obj);
     
   const std::string &label = model->getLabel (construction, *objWrap, part);
+  static int counter = 0;
+  ++counter;
+  cout << "label: " << label << " ," << counter << endl;
     
   return (!label.empty ()) ? strdup (label.c_str ()) : NULL;
 }
diff --git a/elementaryxx/src/Makefile.am b/elementaryxx/src/Makefile.am
index ad963c3..9231f69 100644
--- a/elementaryxx/src/Makefile.am
+++ b/elementaryxx/src/Makefile.am
@@ -51,5 +51,7 @@ libelementaryxx_la_SOURCES = \
        GenListItem.cpp  \
        GenListDataModel.cpp  \
        GenListColumnConstructor.cpp \
-       GenListColumnSelector.cpp
+       GenListColumnSelector.cpp \
+       localUtil.cpp \
+       localUtil.h
 

-- 


Reply via email to