graphics: use destructor callback in ref() to avoid self.gc. ref #1270
Merge branch 'enhance-graphics-gc'