Read pattern history before writing the new values.
The pattern history will not be saved correctly when the AdvancedRename tool is used, but the pattern history in the BQM is not updated. Therefore closing digiKam will result in an empty pattern history in the config file because the BQM is the last instance that will be destroyed when closing the main application. This does not fix the problem described in this bugreport, but it is somehow related. CCBUG:312332