[QGIS-trac] [Quantum GIS] #2700: Adding a layer from py plugin, with QgsVectorLayer.setEditFormInit (QString function) set

Quantum GIS qgis at qgis.org
Sat May 8 14:58:51 EDT 2010


#2700: Adding a layer from py plugin, with QgsVectorLayer.setEditFormInit (QString
function) set
---------------------------------------------------------+------------------
   Reporter:  jaanussuvi                                 |              Owner:  borysiasty                              
       Type:  bug                                        |             Status:  new                                     
   Priority:  critical: causes crash or data corruption  |          Milestone:  Version 1.5.0                           
  Component:  Python plugins and bindings                |            Version:  1.4.0                                   
   Keywords:  QgsVectorLayer setEditFormInit             |   Platform_version:  Quantum GIS 1.4 -   code revision  12728
   Platform:  Windows                                    |           Must_fix:  Yes                                     
Status_info:  0                                          |  
---------------------------------------------------------+------------------
 Briefly about my case:
 I created a python plugin,
 and it creates QgsVectorLayer's from Postgis database.
 I do add qml styles to my layers, with layer.loadNamedStyle(path_to_qml).
 And in qml i've specified form init functions in python
 <editforminit>myInitMethod</editforminit>
 I'm trying to initilize some data fields with editforminit function.

 The problem:[[BR]]

 1) i add a layer with my plugin


 2) select the added layer which has <editforminit> specified


 3) toggle the layer to edit mode


 4) try to add a layer object to map, click on the map


 5) then qgis always craches

 Problem is only when i have set editforminit function.




 [[BR]]
 [[BR]]



 but if i do
 steps


 * (save project)


 * (close and open qgis)


 before adding new object to my layer, then editforminit function is
 invoked and everything works.


 Maybe there's a workaround?
 Maybe some refreshing?

 I do after adding layers:


 self.iface.refreshLegend(myLayer)


 self.iface.mapCanvas().refresh()

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/2700>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list