| 126 | } |
| 127 | |
| 128 | LibrariesUpdateCoordinator::UpdateRequestResult LibrariesUpdateCoordinator::startUpdate(const QStringList &paths) |
| 129 | { |
| 130 | QMutexLocker locker(&futureMutex); |
| 131 | |
| 132 | if (updateFuture.valid() && updateFuture.wait_for(std::chrono::seconds(0)) != std::future_status::ready) { |
| 133 | return UpdateRequestResult::AlreadyRunning; |
| 134 | } |
| 135 | |
| 136 | canceled = false; |
| 137 | |
| 138 | QStringList targets = paths; |
| 139 | if (targets.isEmpty()) { |
| 140 | for (const auto &library : libraries.getLibraries()) { |
| 141 | targets.append(library.getPath()); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | updateFuture = std::async(std::launch::async, [this, targets] { |
| 146 | emit updateStarted(); |
| 147 | for (const auto &path : targets) { |
| 148 | if (!canceled) { |
| 149 | updateLibrary(path); |
| 150 | } |
| 151 | } |
| 152 | emit updateEnded(); |
| 153 | }); |
| 154 | |
| 155 | return UpdateRequestResult::Started; |
| 156 | } |
| 157 | |
| 158 | void LibrariesUpdateCoordinator::updateLibrary(const QString &path) |
| 159 | { |
nothing calls this directly
no test coverage detected