Page 1 of 1

[FIXED] Error re-opening configuration of mouse MoveRelative

Posted: Tue Nov 11, 2008 1:18 am
by magao
EventGhost 0.3.6.1484, Windows XP SP3

Once the Move Relative (Change Mouse Position) action has created, it is not possible to re-open the configuration for it, getting the exception:

Code: Select all

Error while configuring: Change Mouse position by x:None, y:-100
Traceback (most recent call last):
  File "C:\Program Files\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 305, in OnLeftDoubleClick
    eg.UndoHandler.Configure().Try(self.document)
  File "C:\Program Files\EventGhost\eg\Classes\UndoHandler\Configure.py", line 29, in Try
    eg.Greenlet(self.Do).switch(item)
  File "C:\Program Files\EventGhost\eg\Classes\UndoHandler\Configure.py", line 54, in Do
    newArgs = gr.switch(*item.GetArgs())
  File "C:\Program Files\EventGhost\plugins\Mouse\__init__.py", line 401, in Configure
    xCtrl.Enable(False)
UnboundLocalError: local variable 'xCtrl' referenced before assignment
The problem is this code (plugins/Mouse/__init__.py, lines 399-412):

Code: Select all

if x is None:
    x = 0
    xCtrl.Enable(False)
xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)

yCB = panel.CheckBox(y is not None, text.text3)
def HandleYCheckBox(event):
    yCtrl.Enable(event.IsChecked())  
yCB.Bind(wx.EVT_CHECKBOX, HandleYCheckBox)    

if y is None:
    y = 0
    yCtrl.Enable(False)
yCtrl = panel.SpinIntCtrl(y, min=-maxint-1, max=maxint)
which needs to be changed to:

Code: Select all

xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)
if x is None:
    x = 0
    xCtrl.Enable(False)

yCB = panel.CheckBox(y is not None, text.text3)
def HandleYCheckBox(event):
    yCtrl.Enable(event.IsChecked())  
yCB.Bind(wx.EVT_CHECKBOX, HandleYCheckBox)    

yCtrl = panel.SpinIntCtrl(y, min=-maxint-1, max=maxint)
if y is None:
    y = 0
    yCtrl.Enable(False)

Re: Error re-opening configuration of mouse Move Relative action

Posted: Tue Nov 11, 2008 8:49 am
by jinxdone
Hello.

The problem you described was caused by the 'None' value in your configuration. However as for the fix I went for this instead:

Code: Select all

        if x is None:
            x = 0
            xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)
            xCtrl.Enable(False)
        else:
            xCtrl = panel.SpinIntCtrl(x, min=-maxint-1, max=maxint)
The bug was present in both move absolute and move relative actions in the config dialog's x and y value handling when value is 'None'. You can get the fixed __init__.py from the svn or just wait for the next beta build.


Thanks for bringing this issue up. :)

-jinxdone

Re: Error re-opening configuration of mouse Move Relative action

Posted: Tue Nov 11, 2008 11:00 am
by Bitmonster
Funny no one has noticed this before, as the code hasn't been changed for a pretty long time. I incorporated a fix in some other way as jinxdone wrote, as I didn't saw he has committed his change and I also changed some other minor things, so I preferred to simple overwrite his commit.

Re: [FIXED] Error re-opening configuration of mouse MoveRelative

Posted: Tue Nov 11, 2008 12:57 pm
by jinxdone
I would assume people usually leave the settings to '0' rather than 'None', so maybe that's why it hasn't been noticed earlier.. Also looking at the diff to your patch I see you did basically the same thing but in a more python-like manner compared to mine. :)