Fix debug build with non-MSVC compilers

Only add debug flags for MSVC when building with that compiler
Add missing checks for destroyed objects

Fix crash if an object is destroyed in between the inspector
querying the tree and fetching an object