MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / onVerifyClicked

Method onVerifyClicked

pcsx2-qt/Settings/GameSummaryWidget.cpp:271–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void GameSummaryWidget::onVerifyClicked()
272{
273 // Can't do this while a VM is running because of stupid CDVD.
274 if (QtHost::IsVMValid())
275 {
276 QMessageBox::critical(QtUtils::GetRootWidget(this), tr("Error"), tr("Cannot verify image while a game is running."));
277 return;
278 }
279
280 IsoHasher hasher;
281 Error error;
282 if (!hasher.Open(m_entry_path, &error))
283 {
284 QString message(QString::fromStdString(error.GetDescription()));
285 QMessageBox::critical(QtUtils::GetRootWidget(this), tr("Error"), message);
286 return;
287 }
288
289 QtModalProgressCallback callback(this);
290 hasher.ComputeHashes(&callback);
291 if (callback.IsCancelled())
292 return;
293
294 const int hash_column = hasher.IsCD() ? 5 : 4;
295 int row = 0;
296
297 // convert to database format
298 std::vector<GameDatabase::TrackHash> thashes;
299 thashes.reserve(hasher.GetTrackCount());
300 for (const IsoHasher::Track& track : hasher.GetTracks())
301 {
302 GameDatabase::TrackHash thash;
303 thash.size = track.size;
304 if (track.hash.empty() || !thash.parseHash(track.hash))
305 {
306 m_ui.verify->setEnabled(false);
307 m_ui.verifyResult->setPlainText(tr("One or more tracks is missing."));
308 return;
309 }
310
311 // Use the first track's hash as the redump search term.
312 if (m_redump_search_keyword.empty())
313 m_redump_search_keyword = thash.toString();
314
315 thashes.push_back(thash);
316 }
317
318 // match the hashes. can't use vector<bool> here because it's not an actual array
319 std::unique_ptr<bool[]> val_results = std::make_unique<bool[]>(hasher.GetTrackCount());
320 std::string match_error;
321 const GameDatabase::HashDatabaseEntry* hentry =
322 GameDatabase::lookupHash(thashes.data(), thashes.size(), val_results.get(), &match_error);
323
324 // fill the UI with both the hashes and validation results
325 for (u32 i = 0; i < hasher.GetTrackCount(); i++)
326 {
327 QTableWidgetItem* const hash_item = m_ui.tracks->item(row, hash_column);
328 QTableWidgetItem* const status_item = m_ui.tracks->item(row, hash_column + 1);

Callers

nothing calls this directly

Calls 15

GetRootWidgetFunction · 0.85
GetDescriptionMethod · 0.80
ComputeHashesMethod · 0.80
IsCDMethod · 0.80
GetTrackCountMethod · 0.80
parseHashMethod · 0.80
argMethod · 0.80
OpenMethod · 0.45
IsCancelledMethod · 0.45
reserveMethod · 0.45
emptyMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected