I don't know what the law is in Canada, but I do know that there are certainly similar aspects.

Many moons ago (in the '80s) I worked for the government, and they had a government sponsored 'education film' about patent rights (software wasn't the issue where I worked). Anyways, it suggested that stuff done at home could be owned by the inventor, if they could prove that the knowledge used in making the invention (or writing the code) was not obtained from work.

I always assumed that this applied for software as well. In other words, if I write code at home, that uses information that I learned at work, then the IP rights belong to the company, but if I wrote code that was completely and totally unrelated to work, and the skills that I used to write the code were not learned at work, then it would be mine.