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

Quantum GIS qgis at qgis.org
Sat Jul 24 19:31:33 EDT 2010


#2700: Adding a layer from py plugin, with QgsVectorLayer.setEditFormInit (QString
function) set
---------------------------------------------------------+------------------
   Reporter:  jaanussuvi                                 |              Owner:                                          
       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:  No                                      
Status_info:  1                                          |  
---------------------------------------------------------+------------------

Comment(by jaanussuvi):

 Replying to [comment:4 wonder]:
 > This could have been fixed recently in r13751, please test again.
 >


 Sorry, I've finished my project with the´plugin, and i do not have
 development environment setup anymore. So it's really time consuming to
 test it. btw the plugin doesn't use custom editform or init function. I
 solved it differently.
 I think this approach was too complex anyway.

 > If the problem persists, please provide further information how to
 replicate the problem. Can you simply add a layer and set a QML with
 "editforminit" function to get the crash (without using the plugin)?

 Yes, if i add a postgis layer to my qgis project with custom editform,
 then it works fine. But if i add postgis layer with python, and try to add
 new object to the layer, then it does not work. But if i save newly
 created layer to gqis project and restart gqis, then it works.

 How to replicate:
 Also complex task, if not having the setup.
 I believe it could be done with python console.

 U should have postgis db and qml for some geo object.
 in qml of course <editforminit>myInitMethod</editforminit>

 Code that creates vector layer from postgis:
 uri = qgis.core.QgsDataSourceURI()
 uri.setDataSource("your_schema", "your_geo_table", "the_geom", subset_sql)
 vl = qgis.core.QgsVectorLayer(uri.uri(), "layer_name", "postgres")
 vl.loadNamedStyle(QString(qml_path + "vl.qml"))
 qgis.core.QgsMapLayerRegistry.instance().addMapLayer(vl, True)
 self.iface.refreshLegend(vl
 self.iface.mapCanvas().refresh()


 Sorry, i'm too busy with new projects.
 I hope my description helps.

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/2700#comment:6>
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