There's no need to perform a deep copy of the underlying c string.
Checked uses on LXR, this method is used in accordance with the new
semantics already.
Details
Diff Detail
- Repository
- R33 KDevPlatform
- Branch
- master
- Lint
Lint Skipped - Unit
Unit Tests Skipped
This is very unsafe. When you put QByteArray anywhere and then destroy the IndexedString it may (eventually) trigger a cleanup of the item repo data, which will make the QByteArray reference destroyed data.
Where is this actually required? If possible, I want to delete the bytearray getter completely, as it can lead to unicode issues.
Right, but "you have been warned" in the documentation.
Where is this actually required? If possible, I want to delete the bytearray getter completely, as it can lead to unicode issues.
Only used in kdevplatform/kdevelop afaics. Just removing seems possible; a few locations (around 10) in oldcpp need fixing (trivial). Will do.
Unfortunately code such as:
ret += KDevelop::IndexedString::fromIndex(contents[a]).byteArray();
would turn a bit unreadable.
Maybe renaming to asByteArray would give sufficient hint the returned value is just a reference, not a copy for now. Otherwise I'd just ditch the patch for now.
I don't like it as-is, as I said. actually, the other unsafe API is could also be removed in the future (i.e. the fromIndex stuff).