Bug report #9523
openProject macro won't load when enable Macros setting set to Ask
|Affected QGIS version:||2.18.11||Regression?:||Yes|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||18113|
If I have a Project with a Macro as shown below, and I set Settings->Options->Enable Macros to "Ask", the openProject macro will never load. If I set Enable Macros to Always, or only for this session, it will load.
In Ask mode:
I open the Project.
I get the security warning in the canvas view.
I click "Enable Macros"
The security warning disappears
The Project loads without the "Hello I am a Macro" Status bar.
In Always or Only this session:
I open the Project
I see the "Hello I am a Macro" Status bar.
If I run the code as a saveProject macro, then the saveProject macro will work for the Ask Setting. So, the Problem is just with openProject.
def openProject(): from qgis.utils import iface from qgis.gui import QgsMessageBar iface.messageBar().pushMessage("Hello I am a Macro", "", level=QgsMessageBar.INFO) def saveProject(): pass def closeProject(): pass
This is the case for QGIS 2.0.1 as well as today's dev Version Qgis 2.1.0 f06e72e, on Windows as well as on Ubuntu.
#6 Updated by Andreas Neumann over 6 years ago
- Affected QGIS version changed from master to 2.18.10
- Description updated (diff)
- Status changed from Closed to Open
Reopening this bug, because there is a regression in 2.18.10
Same behavior as stated. The macro does not run if enabled after asking the user.
Tested on Windows 7, 64bit.
#11 Updated by Andreas Neumann over 6 years ago
I think a fix for 2.18 would be useful. 2.18 will be around for at least 2 years until people have all their favourite plugins ported to 3.x - so it makes sense to still provide 2.18 fixes for at least another year.
Apparently this issue (or a very similar issue) was fixed by you 8 months ago. I don't know what happened in between and why it doesn't work anymore). The workaround to always enable project macros is a bad security practice.