Detailed KDirModel problems (was: Re: KFileTreeView almost fixed - STRANGE STUFF)
Rafael Fernández López
ereslibre at kde.org
Fri Nov 30 18:51:04 GMT 2007
Hi all,
I am leaving right now, and I haven't got time to try to fix it, but I will
try tonight. Meanwhile I'd like to share with you what I've found, since I
consider this a clear showstopper for KDE 4.0.
If we recapitulate, what we had is a KFileTreeView class that is not able to
sort. I added a KDirSortFilterProxyModel to fix that problem, and suddenly
strange things started to happen to the tree. This is directly related to
KDirModel.
Now, all you need to test the problem is to run the test:
kdelibs/kfile/tests/kfiletreeviewtest
Let's try to reproduce the problem:
First, apply the attached patch.
For example, my home folder is located at /home/ereslibre. If we run the
kfiletreeviewtest the tree is located at /. Nice.
Navigate through the tree and expand /home, now collapse it (or leave it as
expanded). Now click on "Home" button. It worked nice. It seems like the
contents of "/home" were cached and when clicking "Home" (that calls to
setCurrentUrl(), that calls to KDirModel::expandToUrl(), that calls to
KDirModel::nodeForUrl()) they were retrieved and the index was found
successfully.
Now, reopen the test.
Click directly on "Home" button... OMG, now you have a nice assertion failure.
Basically:
kfiletreeviewtest(4660)/kio (KDirModel) KDirModelPrivate::nodeForUrl:
CURRENTLY AT "file:///home" WITH 0 ELEMENTS
ASSERT: "it != end" in
file /home/ereslibre/kdesvn/kdelibs/kio/kio/kdirmodel.cpp, line 180
If you comment out the assert [the Q_ASSERT(it != end) on KDirModel], you will
see that if you click the "Home"
button directly when running the test, the view won't move to your "Home"
folder. That is because of the next:
We get for example this output:
KDirModelPrivate::nodeForUrl: What we want is: KUrl("file:///")
KDirModelPrivate::_k_slotNewItems: 20 in KUrl("file:///") index= "[invalid
index, i.e. root]" newRowCount= 20
KDirModelPrivate::nodeForUrl: What we want is: KUrl("file:///home/ereslibre")
KDirModelPrivate::nodeForUrl: Trying with "file:///lost+found"
KDirModelPrivate::nodeForUrl: Trying with "file:///boot"
KDirModelPrivate::nodeForUrl: Trying with "file:///bin"
KDirModelPrivate::nodeForUrl: Trying with "file:///dev"
KDirModelPrivate::nodeForUrl: Trying with "file:///etc"
KDirModelPrivate::nodeForUrl: Trying with "file:///home"
KDirModelPrivate::nodeForUrl: going into "file:///home/"
KDirModelPrivate::nodeForUrl: KUrl("file:///home")
KDirModelPrivate::nodeForUrl: CURRENTLY AT "file:///home" WITH 0 ELEMENTS
KDirModelPrivate::nodeForUrl: child equal or starting with
KUrl("file:///home/ereslibre") not found
That shows in a very clear way that somehow "/home" hasn't been "cached"
or "explored". Therefore, "/home/ereslibre" can never be found.
Remember that if you manually expand the /home node, and then you click on
the "Home" button you will be driven to that node without problems.
Now, try to comment out the checks I added for "result.first == -1" on
KDirModel. What you will see is blank nodes on the "/home" folder. That was
the problem I was trying to solve. If you only apply the
KDirSortFilterProxyModel for sorting the folders, you get blank nodes (that
is what I posted on the previous thread).
It is important to note that you get as much as blank nodes as warnings
printed through the console: kDebug(7008) << "child equal or starting with "
<< url << " not found";.
As I haven't got more time right now, and I have to leave, I will try to find
a solution tonight, or till the weekend, but I really hope David could give a
hand here :)
Bye and thanks,
Rafael Fernández López
GPG Fingerprint: B9F4 4730 43F8 FFDD CC5E BA8E 724E 406E 3F01 D070
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdelibs.diff
Type: text/x-diff
Size: 7450 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071130/a1071479/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071130/a1071479/attachment.sig>
More information about the kde-core-devel
mailing list