Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a layer from py plugin, with QgsVectorLayer.setEditFormInit (QString function) set #12760

Closed
qgib opened this issue May 8, 2010 · 6 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins
Milestone

Comments

@qgib
Copy link
Contributor

qgib commented May 8, 2010

Author Name: jaanussuvi - (jaanussuvi -)
Original Redmine Issue: 2700

Redmine category:python_plugins


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 myInitMethod
I'm trying to initilize some data fields with editforminit function.

The problem:

  1. i add a layer with my plugin

  2. select the added layer which has 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.

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()

@qgib
Copy link
Contributor Author

qgib commented May 11, 2010

Author Name: Giovanni Manghi (@gioman)


Hi,

feedback to your problem the problem would be better asked in the developer mailing list.

@qgib
Copy link
Contributor Author

qgib commented May 25, 2010

Author Name: Alex Mandel (Alex Mandel)


Needs to be retested on a newer trunk, not a showstopper for release.

@qgib
Copy link
Contributor Author

qgib commented Jun 20, 2010

Author Name: Martin Dobias (@wonder-sk)


This could have been fixed recently in 52a49c9 (SVN r13752), please test again.

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)?

@qgib
Copy link
Contributor Author

qgib commented Jul 24, 2010

Author Name: Giuseppe Sucameli (@brushtyler)


No user's inputs for 5 weeks...
I tick the "awaiting user input" checkbox and hope.

@qgib
Copy link
Contributor Author

qgib commented Jul 24, 2010

Author Name: jaanussuvi - (jaanussuvi -)


Replying to [comment:4 wonder]:

This could have been fixed recently in 52a49c9 (SVN r13752), 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 myInitMethod

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.

@qgib
Copy link
Contributor Author

qgib commented Sep 19, 2010

Author Name: Paolo Cavallini (@pcav)


Closing it pending reporter check. Please reopen it if necessary.


  • resolution was configured as fixed
  • status_id was changed from Open to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins labels May 24, 2019
@qgib qgib added this to the Version 1.6.0 milestone May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins
Projects
None yet
Development

No branches or pull requests

1 participant