yuzu/debugger/graphics_surface: Display error messages for file I/O errors
This commit is contained in:
parent
845607481c
commit
c0e320ad0d
|
@ -7,6 +7,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
@ -477,9 +478,16 @@ void GraphicsSurfaceWidget::SaveSurface() {
|
||||||
const QPixmap* const pixmap = surface_picture_label->pixmap();
|
const QPixmap* const pixmap = surface_picture_label->pixmap();
|
||||||
ASSERT_MSG(pixmap != nullptr, "No pixmap set");
|
ASSERT_MSG(pixmap != nullptr, "No pixmap set");
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file{filename};
|
||||||
file.open(QIODevice::WriteOnly);
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
pixmap->save(&file, "PNG");
|
QMessageBox::warning(this, tr("Error"), tr("Failed to open file '%1'").arg(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pixmap->save(&file, "PNG")) {
|
||||||
|
QMessageBox::warning(this, tr("Error"),
|
||||||
|
tr("Failed to save surface data to file '%1'").arg(filename));
|
||||||
|
}
|
||||||
} else if (selected_filter == bin_filter) {
|
} else if (selected_filter == bin_filter) {
|
||||||
auto& gpu = Core::System::GetInstance().GPU();
|
auto& gpu = Core::System::GetInstance().GPU();
|
||||||
const std::optional<VAddr> address = gpu.MemoryManager().GpuToCpuAddress(surface_address);
|
const std::optional<VAddr> address = gpu.MemoryManager().GpuToCpuAddress(surface_address);
|
||||||
|
@ -487,11 +495,21 @@ void GraphicsSurfaceWidget::SaveSurface() {
|
||||||
const u8* const buffer = Memory::GetPointer(*address);
|
const u8* const buffer = Memory::GetPointer(*address);
|
||||||
ASSERT_MSG(buffer != nullptr, "Memory not accessible");
|
ASSERT_MSG(buffer != nullptr, "Memory not accessible");
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file{filename};
|
||||||
file.open(QIODevice::WriteOnly);
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
const int size = surface_width * surface_height * Tegra::Texture::BytesPerPixel(surface_format);
|
QMessageBox::warning(this, tr("Error"), tr("Failed to open file '%1'").arg(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int size =
|
||||||
|
surface_width * surface_height * Tegra::Texture::BytesPerPixel(surface_format);
|
||||||
const QByteArray data(reinterpret_cast<const char*>(buffer), size);
|
const QByteArray data(reinterpret_cast<const char*>(buffer), size);
|
||||||
file.write(data);
|
if (file.write(data) != data.size()) {
|
||||||
|
QMessageBox::warning(
|
||||||
|
this, tr("Error"),
|
||||||
|
tr("Failed to completely write surface data to file. The saved data will "
|
||||||
|
"likely be corrupt."));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
UNREACHABLE_MSG("Unhandled filter selected");
|
UNREACHABLE_MSG("Unhandled filter selected");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue