actually, the Xinjiang problem started when the whole of China was overrun by the Taiping rebellion (jiangnan), Nian rebellion (henan-hebei), Lilan rebellion (sichuan), red turban rebellion (guangdong), small sword rebellion (fujian), the panthay rebellion (yunnan), the dungan rebellion (gansu). There was really nothing much that could be done. they decided to kick us when we were down. and the british empire, the ottomans, and the Khanate of kokand all helped to mess around in xinjiang.
As for the Russians, they did occupy Ili in the 1870s but the Qing massed modernised regiments in Xinjiang and forced the Russians to pull out (Treaty of St Petersburg 1881, which was seen by most Western powers as a humiliation for Russia)
whether now or then, everyone will only going to come for us when we are down and completely unprepared to fight. it's not enough to say: "the leadership was bad" because it will give modern Chinese a false sense of security as if that having a strong government is enough. you never know when there will be internal disorder, economic problems, or natural disasters all coinciding