Getting Stuck and Unstuck - GSoC'22 post #8

⌂ home      ⇧ one level up
Thu Jul 21, 2022 · 535 words · 3 min

I made progress - on getting stuck in my work.

In my meet with my mentors last week, we decided I'll work on the Space home page while finalizing the merge request I had opened.

Getting Space Home Page on Stack

I wrote a new QML file, which I later realised I couldn't figure out an easy method for passing data to. So my Space home page was populated with hardcoded dummy data. (lorem ipsum 👍)


So, to view how the UI looks, I'll need to view it, right? Yes of course. But the problem here was that once I added the Spce home page on page stack on right pane of NeoChat, I couldn't close it. Neither could I open any room.

Removing the offending piece of code should fix it, right? Yes?


Something about the cache that NeoChat stores to restore state on startup was not letting me exit the Space home page. Too bad. Thankfully Tobias told me which cache file to delete and I was back up running.

Caching Space Hierarchy on Startup

I wrote a function SortFilterRoomListModel ::cacheSpaceHierarchy() that is supposed to be fired when the class constructor is called and will query /hierarchy for each space to cache the list of their child rooms. This caching will let NeoChat instantly update UI when filtering rooms. SortFilterRoomListModelt they were the logs I expected so why should I cry. Room lists were being cached.

Next problem was that I couldn't access the cached room list while filtering. The map was empty always. Why? I didn't know. I did my old school debugging i.e. sticking up print statements all over the place. Some qInfo() later, I got to realize there are not just two instances of SortFilterRoomListModel, but there are actually THREE. Nice. Whats worse is that for the third one, the cache function wasn't being called at all and this third one is what was presented to user.

The issue was too peculiar to me, and will all evidences gathered, it seemes like quite a long issue to explain over chat to my mentors. Thankfully, that was two days back; today I had a call with Tobias, who cleared the air of mystery.

Untangling Myself

Tobias told me there were indeed multiple instances of SortFilterRoomListModel which I shouldn't care about. What I should care about is that the instance shown to the user isn't working as expected. He took a look at my code and traced down the issue to something I personally wouldn't have suspected.

connect(&Controller::instance(), &Controller::activeConnectionChanged, this, [this]() {

This is how I was calling cacheSpaceHierarchy(). Looks fine, EXCEPT that this connection is made only after the signal we're waiting for (Controller ::activeConnectionChanged) has already been fired. The signal doesn't fire again and caching function is never called. The solution was to add another call to cacheSpaceHierarchy() outside of this connection.

Such an easy fix.

About my problem with not being able to exit Space home page, Tobias suggested I try pushing page onto pageStack.layers instead of pageStack like I was doing.

Certain things are easy, but I end up complicating them for no reason.

blog · about · matrix · github · kde invent · endeavour · twitter · email · home