[Qgis-developer] Changes to vector layers persist between python integration tests.
Hi, I am having trouble with integration tests that I am writing in a Python plugin. The tests run correctly one at a time, but when I run them together only the first test works correctly. It seems that changes it makes to the database are still present in the later tests. How can I make sure that the vector layer / database is fully reset between tests? My tests are based on unittest.TestCase. The QGIS app is started with QGISAPP.initQGIS() as in the main QGIS tests and a Mock iface is used. In the setUp, I make a temporary copy of a template spatialite file and run an SQL script on it to add features and other data. I connect to the database and store a reference to it (self.db). Then I load one of the tables as a QgsVectorLayer and store a reference to it (self.esu). The first test uses self.esu.dataProvider().deleteFeatures() to remove features, the second uses self.esu.dataProvider().addFeatures() to add features. They check that the features have been added and that other database changes have been made. The teardown contains the following: if self.db: # Just in case self.db doesn't get set self.db.close() del self.db QSqlDatabase.removeDatabase('integration_testing') self.esu = None reg = QgsMapLayerRegistry.instance() reg.removeAllMapLayers() reg.clearAllLayerCaches() if os.path.exists(self.test_db_path): os.remove(self.test_db_path) I thought that this would be enough to reset any references to the vector layer, but if I delete a feature in the first test, it is still gone when I run the second test. Is QGIS holding any other references to the layers that I have missed? Cheers John John Stevenson Senior Developer [cid:image2a0dbf.PNG@4f0f9f2e.48a467c6]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:image33abae.PNG@3495c8f4.468535fe]<https://twitter.com/thinkWhere1> [cid:imagea91387.PNG@4d22f1ca.4db4dc83] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Problem definig snapping options programmatically
Hi all, This is the same issue that I had a few months ago [1]. (Thanks Tom for flagging it up). You can recreate in the console as follows as follows (QGIS 2.14.3, with one vector layer loaded): ``` vlayer = QgsMapLayerRegistry.instance().mapLayers().values()[0] proj = QgsProject.instance() proj.setSnapSettingsForLayer(vlayer.id(), True, QgsSnapper.SnapToVertex, QgsTolerance.LayerUnits, 5.0, False) ``` The settings are not applied. "Settings > Snapping Options > Snapping Mode" remains at "Current Layer". Changing this to to "Advanced" shows correct values have been set, but they are not activated until "Apply" is pressed. Connecting a function to QgsProject.instance().snapSettingsChanged() shows that the signal fires with no arguments when setSnapSettingsForLayer is called. Emitting the signal manually does nothing. Cheers John [1]: http://osgeo-org.1560.x6.nabble.com/Setting-snapping-settings-via-Python-td5246362.html John Stevenson Senior Developer Email:mailto:john.steven...@thinkwhere.com Glendevon House Castle Business Park Stirling FK9 4TZ Tel: 01786 476060 Tel: 01786 476093 (Direct Dial) From: Qgis-developer [qgis-developer-boun...@lists.osgeo.org] on behalf of Matthias Kuhn [matth...@opengis.ch] Sent: 23 June 2016 14:55 To: qgis-developer@lists.osgeo.org Subject: Re: [Qgis-developer] Problem definig snapping options programmatically Hi Christian, Does it help if you call QgsProject.instance().snapSettingsChanged() Cheers Matthias On 06/23/2016 03:38 PM, EFTAS Christian Röttger wrote: > Hi developers, > > > > i’m facing a problem which i do not understand. In our plugin I created > a function to set snapping options and bound it to a shortcut. > > Using Qgis 2.14.3, source code see below. > > > > The assigned shortcut works well, but for the snapping I have to do the > following on every QGIS start: > > Go to snapping options, mode = advanced, press ok (without changing > anything). Then it works afterwards! > > But when I print the options *before* I do this, I definitely get the > right options (see below). > > > > Does anyone know what I’m missing? Should I open an bug report? Is there > a workaround do do: “Go to snapping options, mode = advanced, press ok” > programmatically ? > > > > Thanks for any help > > Christian > > > > ## Print result > > Initialize, when aggroInstance is true > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > checked > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, True, 2, 0, 2.0, False) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > (True, True, 2, 0, 2.0, False) > > (True, False, 2, 0, 2.0, True) > > (True, False, 2, 0, 2.0, True) > > > > ## function > > > > *def *toggleSnapping(checked): > /''' > Toggle snapping option > /*:param*/checked: True if snapping has been activated, False otherwise > ''' > /aggroInstance = initModule.aggroInstance > *print **'Initialize' > **if *bool(agroInstance): > *for *item *in *QgsMapLayerRegistry.instance().mapLayers().values(): > QgsProject.instance().setSnapSettingsForLayer(item.id(), > False, 2, 0, 2, True) > fieldLayer = > mapUtils.getLayerByName(aggroInstance.dictData[*'field'*]) > backgroundLayer = mapUtils.getLayerByName(*'bg'*) > *for *item *in *QgsMapLayerRegistry.instance().mapLayers().values(): > *print *QgsProject.instance().snapSettingsForLayer(item.id()) > *if *checked: > *print **'checked' > */# Convenience function to set snap settings per layer. > # it defines the snapping options: > # id : the id of your layer, True : to enable the layer > snapping, 2 : options (2: vertex+segment), 0: type of unit on map, 2 : > tolerance, true : avoidIntersection) > > /QgsProject.instance().setSnapSettingsForLayer(fieldLayer.id(), True, 2, > 0, 2, False) > > QgsProject.instance().setSnapSettingsForLayer(backgroundLayer.id(), > True, 2, 0, 2, False) > *for *item *in > *QgsMapLayerRegistry.instance().mapLayers().values(): > *print > *QgsProject.instance().snapSettingsForLayer(item.id()) > > > > ## initialization in run() method > > > > /# Call Snapping Tool by a key shortcut > /*for *action *in *self.actions:
Re: [Qgis-developer] QGIS crashes when doing a rollback after modifying values of an user-added feature with pyQGIS
Hi Manuel, I struggled with a similar problem. Another possible workaround is waiting until the user has saved their edits. You can then catch the commitedFeaturesAdded signal and update the layer directly using the provider. This method has the advantage that the fid that refers to the feature at this stage is the final one and does not change. See this Stack Overflow page for more info: http://gis.stackexchange.com/questions/176686/automatically-updating-user-edited-features-in-qgis-plugin/177594#177594 Cheers John John Stevenson Senior Developer Email:mailto:john.steven...@thinkwhere.com Glendevon House Castle Business Park Stirling FK9 4TZ Tel: 01786 476060 Tel: 01786 476093 (Direct Dial) From: Qgis-developer [qgis-developer-boun...@lists.osgeo.org] on behalf of Martin Dobias [wonder...@gmail.com] Sent: 06 March 2016 08:52 To: Manuel Hernández Martínez Cc: Qgis-developer@lists.osgeo.org Subject: Re: [Qgis-developer] QGIS crashes when doing a rollback after modifying values of an user-added feature with pyQGIS Hi Manuel On Fri, Mar 4, 2016 at 10:05 PM, Manuel Hernández Martínez <mhernand...@agenciamedioambienteyagua.es> wrote: > > self.iface.mapCanvas().currentLayer().featureAdded.connect(self._debug_onFeatureAdded) > > def _debug_onFeatureAdded(self, fid): > layer = self.iface.mapCanvas().currentLayer() > layer.beginEditCommand("Set UUID") > print layer.changeAttributeValue(fid, > layer.fieldNameIndex('guid_pol'), 'some_random_uuid') # prints True > layer.endEditCommand() > > [...] > > When I edit the layer, if I add a feature the field 'guid_pol' is set to > 'some_random_uuid' as expected. I can commit the changes without a problem, > however if instead of committing the changes I try cancelling them QGIS > crashes with error 0xC005 (Access Violation). Unfortunately this is currently a limitation of our current editing system... When an editing signal (like "featureAdded") is emitted, doing some extra editing actions will corrupt the undo stack because the undo command of the previous action is not yet finished. A possible workaround could be to use queued signal/slot connection instead of direct connection (which is the default), so the slot execution will be delayed, and the undo stack will get to a consistent state. Regards Martin ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Setting snapping settings via Python
Thanks for help so far. These suggestions seem to be more complicated than I require. I do not need to use the snapper to modify geometries in a custom tool, just to turn snapping on for the current layer when the user begins editing it. I tried the following, based on Etienne's inasafe example, but nothing happens: layer = canvas.layer(0) point_locator = QgsPointLocator(layer) units = QgsTolerance.LayerUnits layer_config = QgsSnappingUtils.LayerConfig(layer, point_locator.Types(), 50, units) snapper = QgsSnappingUtils() snapper.setLayers([layer_config]) snapper.setSnapToMapMode(QgsSnappingUtils.SnapAdvanced) Is there another snapper already created by QGIS when editing begins that I can access? Cheers John John Stevenson Senior Developer [cid:image8bc20c.PNG@67520999.41b46f51]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:image295644.PNG@b1051cba.4e97df2b]<https://twitter.com/thinkWhere1> [cid:imagea7a708.PNG@070b5c8d.4fa6e904] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. From: Qgis-developer [qgis-developer-boun...@lists.osgeo.org] on behalf of Thomas Gratier [osgeo.mailingl...@gmail.com] Sent: 21 January 2016 11:04 To: Tom Chadwin Cc: qgis-developer Subject: Re: [Qgis-developer] Setting snapping settings via Python Hi, I'm maybe wrong but you'd better look at QgsSnappingUtils http://qgis.org/api/classQgsSnappingUtils.html It seems more simple and should do the job for you. Cheers Thomas Gratier 2016-01-20 20:32 GMT+01:00 Tom Chadwin <tom.chad...@nnpa.org.uk<mailto:tom.chad...@nnpa.org.uk>>: This old thread might also help: http://osgeo-org.1560.x6.nabble.com/getting-QgsMapCanvasSnapper-to-work-td4147067.html -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Setting-snapping-settings-via-Python-tp5246362p5246373.html Sent from the Quantum GIS - Developer mailing list archive at Nabble.com. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org<mailto:Qgis-developer@lists.osgeo.org> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Setting snapping settings via Python
I have now managed to change the settings for an individual layer, via the QgsProject class. But this method only works if the snapping mode is set to 'Advanced' in the GUI dialog (Settings > Snapping Options). proj = QgsProject.instance() proj.setSnapSettingsForLayer(layer.id(), True, QgsSnapper.SnapToVertexAndSegment, QgsTolerance.LayerUnits, 5.0, False) Is there a way to set this snapping mode via Python? Thanks John John Stevenson Senior Developer [cid:image6f4c18.PNG@f30681fe.4690ed71]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:imagecff972.PNG@262d976b.4a8cbca9]<https://twitter.com/thinkWhere1> [cid:image43e08f.PNG@b83ed55e.4f9fea1d] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. ____ From: John Stevenson Sent: 22 January 2016 11:57 To: Thomas Gratier; Tom Chadwin Cc: qgis-developer Subject: RE: [Qgis-developer] Setting snapping settings via Python Thanks for help so far. These suggestions seem to be more complicated than I require. I do not need to use the snapper to modify geometries in a custom tool, just to turn snapping on for the current layer when the user begins editing it. I tried the following, based on Etienne's inasafe example, but nothing happens: layer = canvas.layer(0) point_locator = QgsPointLocator(layer) units = QgsTolerance.LayerUnits layer_config = QgsSnappingUtils.LayerConfig(layer, point_locator.Types(), 50, units) snapper = QgsSnappingUtils() snapper.setLayers([layer_config]) snapper.setSnapToMapMode(QgsSnappingUtils.SnapAdvanced) Is there another snapper already created by QGIS when editing begins that I can access? Cheers John From: Qgis-developer [qgis-developer-boun...@lists.osgeo.org] on behalf of Thomas Gratier [osgeo.mailingl...@gmail.com] Sent: 21 January 2016 11:04 To: Tom Chadwin Cc: qgis-developer Subject: Re: [Qgis-developer] Setting snapping settings via Python Hi, I'm maybe wrong but you'd better look at QgsSnappingUtils http://qgis.org/api/classQgsSnappingUtils.html It seems more simple and should do the job for you. Cheers Thomas Gratier 2016-01-20 20:32 GMT+01:00 Tom Chadwin <tom.chad...@nnpa.org.uk<mailto:tom.chad...@nnpa.org.uk>>: This old thread might also help: http://osgeo-org.1560.x6.nabble.com/getting-QgsMapCanvasSnapper-to-work-td4147067.html -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Setting-snapping-settings-via-Python-tp5246362p5246373.html Sent from the Quantum GIS - Developer mailing list archive at Nabble.com. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org<mailto:Qgis-developer@lists.osgeo.org> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] Setting snapping settings via Python
Hi, Is there a way to set the snapping settings for a layer via Python? I would like to turn on snapping with a specified tolerance automatically when a user begins editing within a plugin. There is a question on gis.stackexchange, but it hasn't been answered. http://gis.stackexchange.com/questions/133816/how-to-enable-the-snapping-options-for-vector-layer-using-the-python-programming QSettings stores some values, but these are the defaults: qs = QSettings() qs.value('Qgis/digitizing/default_snap_mode') qs.value('Qgis/digitizing/default_snapping_tolerance') qs.value('Qgis/digitizing/default_snapping_tolerance_units') I have also found the canvas.snappingUtils(), but cannot find functions there to enable snapping modes or set tolerances. Thanks, John John Stevenson Senior Developer [cid:image985e2b.PNG@7eaab0b3.4abdcafe]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:imageb46136.PNG@a13dc9e0.43bf4b39]<https://twitter.com/thinkWhere1> [cid:image064812.PNG@9af40f23.4298b90c] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] Disable undo feature for user geometry edits within plugin / general undoStack() questions
Hi, I am writing a plugin that modifies a spatialite database in response to geometry edits made by the user. The attribute table for the modified feature is modified when an item is added or edited, and additional tables within the database are updated with the new information. The undo button does not revert the database changes (and can cause crashed in Linux), so I would like to prevent the user being able to use it. So far, I have worked out how to disable the undo button (and shortcut) by disabling the corresponding action. But when I connect that to a signal, it fires but the undo is still enabled, but with a different corresponding action. So far I have a class that initiates on beginEditing whose contents include the following: ``` def __init__(self, iface, layer, db): . various lines here self.undo_stack = layer.undoStack() def connect_signals(self): various lines here self.undo_stack.indexChanged.connect(self.disable_undo_button) self.undo_stack.canUndoChanged.connect(self.disable_undo_button) self.undo_stack.cleanChanged.connect(self.disable_undo_button) self.undo_stack.undoTextChanged.connect(self.disable_undo_button) def disable_undo_button(self): """ Disable GUI undo buttons to prevent user trying to undo edits, which is prone to causing crashes. """ print('Disabling undo button') actions_to_disable = ['', ''] for action in self.iface.editMenu().actions(): menu_item_action_text = action.text() if menu_item_action_text in actions_to_disable: action.setDisabled(True) print(id(action)) ``` The disable_undo_button() function works, so it seems that another action is being added as the current undo without any of the signals that I am listening for being called. - When is the final change made to the undoStack? - Is there a signal that I can listen for to disable undo afterwards? - or is there generally a better way to disable undo functionality? Cheers John John Stevenson Senior Developer [cid:imaged86623.PNG@a338e0da.42aa3eed]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:imagec95a8b.PNG@7b323e42.469672cb]<https://twitter.com/thinkWhere1> [cid:image5e2fd2.PNG@3bddb98a.4893db0f] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] Undo command crashes QGIS when called from within plugin.
Hi, I have code within a plugin that I am writing that is similar to: ``` def feature_added(self, fid): self.vlayer.beginEditCommand('Update attributes') self.vlayer.changeAttributeValue(fid, 2, 17) self.vlayer.endEditCommand() ``` It is called in response to a featureAdded signal from the layer. The command runs and the attributes are updated and the canvas refreshes to show them. However, when I check the undoStack for the layer, the command is not present. When I press 'Undo', QGIS has a hard crash. If I use the QGIS iPython console to access the layer directly through my plugin (e.g. via qgis.utils.plugins['MyPlugin']) and type the equivalent commands directly into the console, everything works as expected, but the changes are not visible until the canvas is manually refreshed. Is there something else that should / shouldn't be called by the plugin to put the undo command onto the stack? I'm on QGIS 2.12.0 on Linux Mint 17 (Ubuntu 14.04). Thanks, John John Stevenson Senior Developer [cid:image6f2e87.PNG@5b109e70.4c82a5fd]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:image93fee1.PNG@76e49b2d.499be68b]<https://twitter.com/thinkWhere1> [cid:imageaf7fc7.PNG@e09bbbf0.4392c48d] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] Plugin: initGui not called on QGIS startup?
Hi, When QGIS starts, it calls the __init__.py and the __init__ method of my plugin, but not the initGui method. Once QGIS has started, the plugin appears in qgis.utils.available_plugins but not in qgis.utils.active_plugins. If I call qgis.utils.startPlugin, then __init__.py, Plugin.__init__ and Plugin.initGui are all called and the plugin becomes active. When is initGui / startPlugin called method during QGIS loading? Is there something that my initGui should contain (or that my __init__ should not contain) so that the initGui gets called on QGIS startup? I’m using QGIS 2.12.0 on Mint 17 Mate (ubuntu 14.04). Thanks, John John Stevenson Senior Developer [cid:image89b64d.PNG@f281b8a7.46bf9c9f]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:image60ad50.PNG@0c2c9505.4bb1cd96]<https://twitter.com/thinkWhere1> [cid:image3b1f3e.PNG@f5d66328.42aaa62e] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Plugin: initGui not called on QGIS startup?
Hi Tom, It is one that I am writing myself. I've looked at others e.g. openlayers, plugin reloader and they all have their initGui methods called, so I am trying to understand why mine is not. Thanks John John Stevenson Senior Developer Email:mailto:john.steven...@thinkwhere.com Glendevon House Castle Business Park Stirling FK9 4TZ Tel: 01786 476060 Tel: 01786 476093 (Direct Dial) -Original Message- From: Qgis-developer [mailto:qgis-developer-boun...@lists.osgeo.org] On Behalf Of Tom Chadwin Sent: 11 November 2015 12:25 To: qgis-developer@lists.osgeo.org Subject: Re: [Qgis-developer] Plugin: initGui not called on QGIS startup? Which plugin? -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Plugin-initGui-not-called-on-QGIS-startup-tp5235698p5235710.html Sent from the Quantum GIS - Developer mailing list archive at Nabble.com. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Plugin: initGui not called on QGIS startup?
Hi Matthias, A very good question. No, I had not. I had just copied the module directory into my plugins directory. Now that it is activated, the initGui and unload methods are begin called on QGIS start up and close down. Thank you! John John Stevenson Senior Developer Email:mailto:john.steven...@thinkwhere.com Glendevon House Castle Business Park Stirling FK9 4TZ Tel: 01786 476060 Tel: 01786 476093 (Direct Dial) -Original Message- From: Qgis-developer [mailto:qgis-developer-boun...@lists.osgeo.org] On Behalf Of Matthias Kuhn Sent: 11 November 2015 13:03 To: qgis-developer@lists.osgeo.org Subject: Re: [Qgis-developer] Plugin: initGui not called on QGIS startup? Hi John, Sorry for a probably a stupid question, but did you activate the plugin in the plugin manager? Matthias On 11/11/2015 01:58 PM, John Stevenson wrote: > Hi Tom, > > It is one that I am writing myself. I've looked at others e.g. openlayers, > plugin reloader and they all have their initGui methods called, so I am > trying to understand why mine is not. > > Thanks > John > > > John Stevenson > Senior Developer > Email:mailto:john.steven...@thinkwhere.com > > Glendevon House > Castle Business Park > Stirling FK9 4TZ > > Tel: 01786 476060 > Tel: 01786 476093 (Direct Dial) > > -Original Message- > From: Qgis-developer [mailto:qgis-developer-boun...@lists.osgeo.org] > On Behalf Of Tom Chadwin > Sent: 11 November 2015 12:25 > To: qgis-developer@lists.osgeo.org > Subject: Re: [Qgis-developer] Plugin: initGui not called on QGIS startup? > > Which plugin? > > > > -- > View this message in context: > http://osgeo-org.1560.x6.nabble.com/Plugin-initGui-not-called-on-QGIS- > startup-tp5235698p5235710.html Sent from the Quantum GIS - Developer > mailing list archive at Nabble.com. > ___ > Qgis-developer mailing list > Qgis-developer@lists.osgeo.org > List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer > > > ___ > Qgis-developer mailing list > Qgis-developer@lists.osgeo.org > List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer -- Help to improve QGIS rendering possibilities before Nov 30, 2015 http://www.opengis.ch/2015/11/02/qgis-crowdfunding-2-5d-rendering ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] Spatialite database locked after layer removal.
Hi, I am having trouble renaming a spatialite database that I have been using in QGIS (2.10.1-Pisa). I have been working in Python, but the problem can be easily recreated through the GUI. 1) Add spatialite layer from sqlite file 2) Remove spatialite layer (right click, remove) 3) Rename or delete the sqlite file Python gives ‘WindowsError’ in Windows 7, or ‘OSError’ in Xubuntu 14.04. The Linux terminal gets: mv: cannot move ‘test.sqlite’ to ‘test2.sqlite’: Text file busy After a few (1-5?) minutes the lock is removed. With shape file layers, the lock is removed as soon as the layer is removed. Is there a reason for the delay with the spatialite file? Is there a command that I can call to refresh/drop the connection more quickly? Thanks, John John Stevenson Senior Developer [cid:image62d446.PNG@b8f67a6f.44b02e71]<http://www.thinkwhere.com> t: 01786 476060 (Office) t: 01786 476093 (Direct Dial) w:www.thinkwhere.com<http://www.thinkwhere.com> Glendevon House Castle Business Park Stirling FK9 4TZ [cid:image4b9582.PNG@2ece2541.49a15f3b]<https://twitter.com/thinkWhere1> [cid:image1d9004.PNG@2583645c.4eb76c05] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis> This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way. thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails. thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer