Merge "Prevent crash when flushing the layers cache Bug #6258973"