Fixes AttributeError: [some plugin] object has no attribute 'cms_plugin_ptr'

In my case, this apparently was triggered by upgrading the CMS whilst having unsaved plugin instances, but this seems like a very safe addition. I mean, if we're going to bother checking to see if inst is valid, shouldn't we also check that the object we're about to access is also valid?