It could've been easily prevented by actually arresting someone that committed abject murder, but the city and the police chose to instead defend a man who has killed multiple people in the past and got away with it scott-free. So when people feel like justice no longer exists, there should be no surprise that they get angry.
It doesn't help that the police also employ agent provocateurs whom help incite riots and looting so that they can use more violent tactics with glee.
I don't know if it could have been prevented by arresting just this murderer, as it's far from an isolated incident.
I do however think it could have been prevented by an edict from the top years ago, issuing a zero-tolerance policy for harassment, abuse and murder by police officers, with focus on clearly racially motivated incidents. I'm fom the UK, so don't claim to understand american politics, but I just don't understand why something like that hasn't happened, especially when Obama was president.