// We start off with an EditTxn since that's what the factory returns.
nsRefPtr<EditTxn> editTxn = new PlaceholderTxn();
// Then we QI to an nsIAbsorbingTransaction to get at placeholder
// have to use line above instead of "plcTxn = do_QueryInterface(editTxn);"
// due to our broken interface model for transactions.
// save off weak reference to placeholder txn
mPlaceHolderTxn = do_GetWeakReference(plcTxn);
editTxn is not used thereafter, only plcTxn. This is outdated -- bug 489851 got rid of the factory functions that the comments refer to, so we could just use nsRefPtr<PlaceholderTxn> here, which requires no QI to be an nsIAbsorbingTransaction. But then do_GetWeakReference doesn't work. What's the right way to work around this?
Hmm, how about:
nsCOMPtr<nsIAbsorbingTransaction> plcTxn = new PlaceholderTxn();
You have the concrete type here, so there's no reason to QI, and the compiler can figure things out using a static cast.
Created attachment 640058 [details] [diff] [review]
Hmm, that works. We still need to QI it to nsITransaction, which isn't maximally elegant, but it's still a lot better. -8 lines of comments complaining about how bad the code is!