rojas.run

Devops and dev stuff

GSOC Update 2

Hello and welcome to my second GSOC update! I think I these last few weeks have been really productive in fixing some issues with my code and getting some direction in the next steps for my project. If you remember last time we had just figured out how to get the SVG option to appear in Krita so we can start testing out saving a test SVG file. We were getting a few errors actually trying to use that option and save the file but those should be all fixed now.

Firstly we were getting a Permission denied: Krita is not allowed to read the file. error when actually trying to save with SVG. At first I thought this was due to how I was trying to use the svgWriter class. The svgWriter assumes that we are only getting to export one layer (the current one) so I thought by trying to save in the context of the whole file, that was tripping it up somehow. After doing some investigation and tracing all the steps in the code this didn’t seem to be the issue.

Hmmmm alright so since my intitial assumption was incorrect lets try starting from the beginning with whats actually producing this error? Well turns out it is from the fail of the check !io->isReadable(). Is this the correct way to check if a file is readable? Well comparing to the check used in an example commit (from amyspark) it seems to use a different method to check if the file is writeable KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(io->isWritable(), ImportExportCodes::NoAccessToWrite);. Thats interesting, lets try commenting our check and see if the file gets created or Krita crashes, either way we’ll get some valuable information. After trying that it the file gets created! An empty file but thats exactly what we expected. Now we’ll replace my incorrect check with the right one.

Next step is get the boilerplate SVG file context written to our empty file. After some investigation it seems like all of the SVG writer code does get executed properly and it does try to write to the file but something is missing. Even when passing the same layer contents to svgWriter it still doesn’t write to that file. Well to make a long story short it turns out you have to actually pass your IO device if you want to actually write to it/use it. After changing my code to pass the current QIODevice it was properly writing to the file!

After figuring out those issues I had a discussion with Wolthera around the next steps for my project. We talked about how I was going to traverse the layers of the Krita file as I was writing to my SVG file. At first I thinking about writing entirely new code, reading the document, and going through layer by layer but then Wolthera introduced me to the intended way to do this process. Namely, by making an implementation for the KisNodeVisitor class that would handle traversing the layers. Instead of trying to re-invent the wheel I can use the standard way Krita accesses file. I started working on that implementation late last week so I’m still figuring out all the details on how it works. Hopefully I’ll be able to talk about my making that next week.

Thanks for tuning in!