#15: SoK with PMC – 2

December was a particularly hectic month. I had my semester exams so could not make time for this project. It was only after 20th of the month that I was back into it.

Anyways, like I said, I implemented the lastfm image fetcher as a plugin. It has an added advantage that you could turn it off if you want to. It’s compiled as a different component, and on runtime acts independently of the main application. Giving signals out to the main application, for information interchange.

Here are some problems I faced in no particular order.

I had to figure out if at all I needed to create a different function for communicating with the mentioned plugin. Of course it was the easier thing to do. But my job was to improve the architecture and keep it from getting complex. So the first few days, I spent figuring out the gist of the code. The interaction with the API and feeding those images back to the UI. I found a signal there, that was emitting the list of newly found media from the local system. Finding this one particular signal, among others was the difficult thing to do, I agree. Next step was easier. Connecting that signal to a slot in my plugin, that would then iterate over this list of media and fetch the images.

Next step that I did, was to update the application UI and to display those images. This time around finding any sort of update signal was easier since I had done this before. Ack came to the rescue and now I know, why my seniors love it. After finding that signal, it was just a matter of connecting the appropriate signals for feeding those images to the UI.

After doing this, I fell into the classic problem of multi threading. Since, my plugin was  an altogether different component now, it was to be run in a different thread. Sounds about right. But here’s the catch. Inside my plugin, I was using QNetworkAccessManager for doing the network related stuff. But this QNetworkAccessManager automatically runs into a different thread to avoid clogging the main thread. So, all this time I was thinking I had 2 threads with respect to lastfm plugin but infact there were 3. The main UI, the plugin, and the Network Manager inside the plugin. I gotmmany warnings in the application output that the application was not able to create children for a parent that was in a different thread. Took me some days to figure it out. And in the process I learned about QThread and general multi-threading concepts. Turns out, that my plugin was already creating an instance for Network Manager in the constructor and the so the Network Manager had it’s thread affinity to that thread. Now during run() , that is what makes a different thread, I was creating children for Network Manager. Once, I had this figured out, all I had to do was direct the run() , to some different slot by emitting a signal. And in that slot, creating instances for everything related to the Network Manager.

So, after this all seemed to work fine. Tested it and everything and was good to go !

Next, I’ll look into a branch that Bhushan made during his Google Summer of Code. It gives a whole new, crisp UI to the application. I actually like this new one. But still, it’s not finished. UI is not ready for online services like picasa, flickr and youtube. And we have ported only grid and list browsers so only those models would work. Also, I’ll have to get those UI components to work. I’ll be looking into it. The only problem being that I don’t know about QML that much. And all this UI stuff is written in QML. So it seems unsettling. But I’ll figure something out 😉


That’s all for now.

Thanks for reading.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s