only call canvas_makefilename() with a proper canvas

avoid more crashes
don't construct dir/filename if both are the same
more braces