<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<!-- Template generated by Exclaimer Mail Disclaimers on 05:06:37 Thursday, 7 January 2016 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">P.414e7b50-9f91-49ff-842d-fa8ec507eb62 {
        MARGIN: 0cm 0cm 0pt
}
LI.414e7b50-9f91-49ff-842d-fa8ec507eb62 {
        MARGIN: 0cm 0cm 0pt
}
DIV.414e7b50-9f91-49ff-842d-fa8ec507eb62 {
        MARGIN: 0cm 0cm 0pt
}
TABLE.414e7b50-9f91-49ff-842d-fa8ec507eb62Table {
        MARGIN: 0cm 0cm 0pt
}
DIV.Section1 {
        page: Section1
}
</style>
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">So far I have a class that initiates on beginEditing whose contents include the following:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">```<o:p></o:p></p>
<p class="MsoNormal">def __init__(self, iface, layer, db):<o:p></o:p></p>
<p class="MsoNormal">    ..... various lines here ....<o:p></o:p></p>
<p class="MsoNormal">    self.undo_stack = layer.undoStack()<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">def connect_signals(self):<o:p></o:p></p>
<p class="MsoNormal">    ....various lines here....<o:p></o:p></p>
<p class="MsoNormal">    self.undo_stack.indexChanged.connect(self.disable_undo_button)<o:p></o:p></p>
<p class="MsoNormal">    self.undo_stack.canUndoChanged.connect(self.disable_undo_button)<o:p></o:p></p>
<p class="MsoNormal">    self.undo_stack.cleanChanged.connect(self.disable_undo_button)<o:p></o:p></p>
<p class="MsoNormal">    self.undo_stack.undoTextChanged.connect(self.disable_undo_button)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">def disable_undo_button(self):<o:p></o:p></p>
<p class="MsoNormal">    """<o:p></o:p></p>
<p class="MsoNormal">   Disable GUI undo buttons to prevent user trying to undo edits, which<o:p></o:p></p>
<p class="MsoNormal">    is prone to causing crashes.<o:p></o:p></p>
<p class="MsoNormal">    """<o:p></o:p></p>
<p class="MsoNormal">    print('Disabling undo button')<o:p></o:p></p>
<p class="MsoNormal">    actions_to_disable = ['&Undo', '&Redo']<o:p></o:p></p>
<p class="MsoNormal">    for action in self.iface.editMenu().actions():<o:p></o:p></p>
<p class="MsoNormal">        menu_item_action_text = action.text()<o:p></o:p></p>
<p class="MsoNormal">        if menu_item_action_text in actions_to_disable:<o:p></o:p></p>
<p class="MsoNormal">            action.setDisabled(True)<o:p></o:p></p>
<p class="MsoNormal">            print(id(action))<o:p></o:p></p>
<p class="MsoNormal">```<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.  <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- When is the final change made to the undoStack?<o:p></o:p></p>
<p class="MsoNormal">- Is there a signal that I can listen for to disable undo afterwards?<o:p></o:p></p>
<p class="MsoNormal">- or is there generally a better way to disable undo functionality?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Cheers<o:p></o:p></p>
<p class="MsoNormal">John<o:p></o:p></p>
</div>
<br>
<table class="414e7b50-9f91-49ff-842d-fa8ec507eb62Table" borderColor="black" cellspacing="0" cols="1" cellpadding="0" width="450" border="0">
<tbody>
<tr>
<td>
<p><span style="font-family:Arial; color: #009F94; font-weight: bold; ">John Stevenson</span><br>
<span style="font-family:Arial; font-size:x-small; ">Senior Developer</span> </p>
</td>
<td style="PADDING-BOTTOM: 5px; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px">
<p class="414e7b50-9f91-49ff-842d-fa8ec507eb62"><a href="http://www.thinkwhere.com"><img id="IMG1" border="0" align="right" src="cid:imaged86623.PNG@a338e0da.42aa3eed"></a></p>
</td>
</tr>
<tr>
<td>
<p><font size="2" face="Arial"><font color="#009f94">t:</font> 01786 476060 (Office)<br>
<font color="#009f94">t:</font> 01786 476093 (Direct Dial)<br>
<font color="#009f94">w:</font><a href="http://www.thinkwhere.com">www.thinkwhere.com</a></font>
</p>
</td>
<td style="PADDING-BOTTOM: 5px; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px">
<p align="right"><font size="2" face="Arial">Glendevon House<br>
Castle Business Park<br>
Stirling FK9 4TZ</font></p>
</td>
</tr>
<tr>
<td><a href="https://twitter.com/thinkWhere1"><img id="IMG1" border="0" align="left" src="cid:imagec95a8b.PNG@7b323e42.469672cb"></a>
<a href="http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis">
<img id="IMG1" border="0" align="left" src="cid:image5e2fd2.PNG@3bddb98a.4893db0f"></a>
</td>
<td style="PADDING-BOTTOM: 5px; PADDING-TOP: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px">
</td>
</tr>
</tbody>
</table>
<br>
<p align="justify"><font color="#7f7f7f" size="1" face="Verdana">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.<br>
<br>
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.<br>
<br>
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.
</p>
<br>
</font>
<p></p>
<p></p>
<p></p>
</body>
</html>