Avoid possible crash in rendering loop
As soon as QgsMapLayer::setCacheImage is called while rendering is active, a crash occurs.
Due to the fact, that processEvents is called from the main rendering loop, such situations cannot always be foreseen.
Merge pull request #500 from matthias-kuhn/rendering-cache-crash

[Bugfix] Make rendering cache more stable