avoid calling QPainter::end() and delete painter multiple times

the whole context is shared before. now only some common data shared,
e.g. painter. we can delete them in each context
TODO: use shared ptr for those common ptr