| 192 | } |
| 193 | |
| 194 | std::shared_ptr<UBDocument> UBDocument::findDocument(std::shared_ptr<UBDocumentProxy> proxy) |
| 195 | { |
| 196 | if (!proxy) |
| 197 | { |
| 198 | return nullptr; |
| 199 | } |
| 200 | |
| 201 | for (int i = 0; i < sDocuments.size();) |
| 202 | { |
| 203 | const auto document = sDocuments.at(i).lock(); |
| 204 | |
| 205 | if (!document) |
| 206 | { |
| 207 | // weak pointer expired, clean up list |
| 208 | sDocuments.removeAt(i); |
| 209 | } |
| 210 | else if (document->mProxy == proxy) |
| 211 | { |
| 212 | // document found |
| 213 | return document; |
| 214 | } |
| 215 | else |
| 216 | { |
| 217 | // check next list entry |
| 218 | ++i; |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | return nullptr; |
| 223 | } |
no test coverage detected