| 1529 | } |
| 1530 | |
| 1531 | void CaptureContext::ExportCapture(const CaptureFileFormat &fmt, const rdcstr &exportfile) |
| 1532 | { |
| 1533 | if(!m_CaptureLocal) |
| 1534 | return; |
| 1535 | |
| 1536 | QString ext = fmt.extension; |
| 1537 | |
| 1538 | ICaptureFile *local = NULL; |
| 1539 | ICaptureFile *file = NULL; |
| 1540 | ResultDetails result = {ResultCode::Succeeded}; |
| 1541 | |
| 1542 | const SDFile *sdfile = NULL; |
| 1543 | |
| 1544 | // if we don't need buffers, we can export directly from our existing capture file |
| 1545 | if(!fmt.requiresBuffers) |
| 1546 | { |
| 1547 | file = m_Replay.GetCaptureFile(); |
| 1548 | sdfile = m_StructuredFile; |
| 1549 | } |
| 1550 | |
| 1551 | if(!file) |
| 1552 | { |
| 1553 | local = file = RENDERDOC_OpenCaptureFile(); |
| 1554 | result = file->OpenFile(m_CaptureFile, "rdc", NULL); |
| 1555 | } |
| 1556 | |
| 1557 | QString filename = QFileInfo(m_CaptureFile).fileName(); |
| 1558 | |
| 1559 | if(!result.OK()) |
| 1560 | { |
| 1561 | RDDialog::critical( |
| 1562 | m_MainWindow, tr("Error opening file"), |
| 1563 | tr("Couldn't open file '%1' for export\n%2").arg(filename).arg(result.Message())); |
| 1564 | |
| 1565 | if(local) |
| 1566 | local->Shutdown(); |
| 1567 | return; |
| 1568 | } |
| 1569 | |
| 1570 | float progress = 0.0f; |
| 1571 | |
| 1572 | LambdaThread *th = new LambdaThread([file, sdfile, ext, exportfile, &progress, &result]() { |
| 1573 | result = file->Convert(exportfile, ext, sdfile, [&progress](float p) { progress = p; }); |
| 1574 | }); |
| 1575 | th->setName(lit("ExportCapture")); |
| 1576 | th->start(); |
| 1577 | // wait a few ms before popping up a progress bar |
| 1578 | th->wait(500); |
| 1579 | if(th->isRunning()) |
| 1580 | { |
| 1581 | ShowProgressDialog( |
| 1582 | m_MainWindow, tr("Exporting %1 to %2, please wait...").arg(filename).arg(QString(fmt.name)), |
| 1583 | [th]() { return !th->isRunning(); }, [&progress]() { return progress; }); |
| 1584 | } |
| 1585 | th->deleteLater(); |
| 1586 | |
| 1587 | if(local) |
| 1588 | local->Shutdown(); |
nothing calls this directly
no test coverage detected