Oxygen: Fix QCache usage

Review Request #127866 - Created May 8, 2016 and submitted

Michael Pyne

This should mostly complete the QCache fixes I kicked off in a previous RR, 127837. Hugo noted there were many other similar usages, and boy he wasn't kidding! ;) The long story short is that these usages can theoretically cause use-after-free behavior (which can lead to crashes and even undefined behavior if the compiler ever gets smart).

NOTE It is -much- easier to review if you download the diff to your git repository for oxygen and then run "git diff -b" to ignore whitespace changes, particularly for the QPixmap changes.

For QPixmaps we return values instead of pointers, so we simply make a separate copy to be cached when we do insert. For QColor we return references to values so we must return pointers, and those have to be owned by a QCache to avoid memleaks. So I added a helper function to loop until the cache accepts the new entry. TileSets are a similar concern, except those have manual loops since I was uncertain about whether TileSet's copy constructor was the best idea or not.

This fixes a ton of Coverity issues (59717 - 259733, 259739, 259742 - 259752, 1336154, 1336155) and might be associated with Qt bug 38142 and KDE bug 219055 (which doesn't actually appear to be a dupe of a different bug to me...).

Compiled without warnings, installed and ran oxygen-demo5 -style oxygen. Used the GUI Benchmark feature to automatically cycle through all the listed features -- no crashes or obvious rendering errors.

Hugo Pereira Da Costa
Michael Pyne
Mark Gaiser
Frank Reininghaus
Hugo Pereira Da Costa
Hugo Pereira Da Costa
Michael Pyne
Review request changed

Status: Closed (submitted)