selecting outside the WT list gives an exception

Bug #396685 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar Explorer
Fix Released
Undecided
Unassigned

Bug Description

If I click on an item in the WT view and then click in the blank space at the bottom, I get:
Traceback (most recent call last):
  File "C:/Users/jameinel/dev/bzr/plugins\explorer\lib\wt_browser.py", line 135, in do_current_chang
ed
    fileinfo = model.fileInfo(model_index)
AttributeError: 'NoneType' object has no attribute 'fileInfo'

I believe it just means that "do_current_changed' needs to handle None as a model_index.

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Can you retest in rev 168? (I can't reproduce this on Ubuntu but the fix looks pretty obvious.)

Changed in bzr-explorer:
status: New → Fix Released
Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 396685] Re: selecting outside the WT list gives an exception

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ian Clatworthy wrote:
> Can you retest in rev 168? (I can't reproduce this on Ubuntu but the fix
> looks pretty obvious.)
>
> ** Changed in: bzr-explorer
> Status: New => Fix Released
>

$ bzr explorer .
Traceback (most recent call last):
  File "C:/Users/jameinel/dev/bzr/plugins\explorer\lib\wt_browser.py",
line 139, in do_current_chang
ed
    self._edit_button.setEnabled(fileinfo and not fileinfo.isDir())
TypeError: argument 1 of QWidget.setEnabled() has an invalid type

You managed to move the data around, but not actually fix it.

I'll also note that in python "X and Y" returns one of the objects. You
might want:
  bool(fileinfo and not fileinfo.isDir())

fileinfo and not fileinfo.isDir()

will return the fileinfo object if it evaluates to false (in the case it
is None, for example)

Doing this:
=== modified file 'lib/wt_browser.py'
- --- lib/wt_browser.py 2009-07-16 12:31:36 +0000
+++ lib/wt_browser.py 2009-07-16 14:45:06 +0000
@@ -136,7 +136,7 @@
             fileinfo = None
         else:
             fileinfo = model.fileInfo(model_index)
- - self._edit_button.setEnabled(fileinfo and not fileinfo.isDir())
+ self._edit_button.setEnabled(bool(fileinfo and not
fileinfo.isDir()))
         self._selected_fileinfo = fileinfo

     def set_root(self, path):

Seemed to make it work. I'm not sure if that is the prettiest way to do
it. You could also do:

edit_is_enabled = True
if fileinfo is None or fileinfo.isDir():
  edit_is_enabled = False
self._edit_button.setEnabled(edit_is_enabled)

Note that it may be a Windows thing, or it may be a PyQt version thing:
>>> PyQt4.QtCore.qVersion()
'4.4.0'

John
=:->

 status in_progress
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpfPXgACgkQJdeBCYSNAAOF9wCfTp+zAYZL+lTkgaoWrGRauyZp
8roAn1Jq+VoRgueAAndXPLYXgmAg5aLX
=dh+3
-----END PGP SIGNATURE-----

John A Meinel (jameinel)
Changed in bzr-explorer:
status: Fix Released → In Progress
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

I'll applied your suggested change (the prettier code). If this is ok now, please mark as Fix Released.

Revision history for this message
John A Meinel (jameinel) wrote :

I can confirm that it no longer gives the traceback and the edit button goes disabled when you click outside the list.

Changed in bzr-explorer:
status: In Progress → Fix Released
Changed in bzr-explorer:
milestone: none → 0.5
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.