summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorEdward Rudd <urkle@outoforder.cc>2014-07-07 17:23:45 -0400
committerEdward Rudd <urkle@outoforder.cc>2014-07-07 17:47:10 -0400
commitb86e993a82d3a68b9ae846515b714cdab3b9154b (patch)
treed7988fc815160faa262a753d73ce1a4e71fa25e3 /gui
parent7f9ec13a30f1b2cc8bdb1a199b7da54b9ab8860f (diff)
fix saving image via right click menu in state inspector
Diffstat (limited to 'gui')
-rw-r--r--gui/mainwindow.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index f10434d1..f588bd6d 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -21,6 +21,7 @@
#include "ui_profilereplaydialog.h"
#include "vertexdatainterpreter.h"
#include "trace_profiler.hpp"
+#include "image/image.hpp"
#include <QAction>
#include <QApplication>
@@ -1270,7 +1271,20 @@ void MainWindow::saveSelectedSurface()
}
QVariant var = item->data(0, Qt::UserRole);
+ if (!var.isValid()) {
+ return;
+ }
+
QImage img = var.value<QImage>();
+ if (img.isNull()) {
+ image::Image *traceImage = ApiSurface::imageFromBase64(var.value<QByteArray>());
+ img = ApiSurface::qimageFromRawImage(traceImage);
+ delete traceImage;
+ }
+ if (img.isNull()) {
+ statusBar()->showMessage( "Failed to save image", 5000);
+ return;
+ }
QString imageIndex;
if (selectedCall()) {
@@ -1311,8 +1325,11 @@ void MainWindow::saveSelectedSurface()
.arg(parentIndex)
.arg(childIndex);
//qDebug()<<"save "<<fileName;
- img.save(fileName, "PNG");
- statusBar()->showMessage( tr("Saved '%1'").arg(fileName), 5000);
+ if (img.save(fileName, "PNG")) {
+ statusBar()->showMessage( tr("Saved '%1'").arg(fileName), 5000);
+ } else {
+ statusBar()->showMessage( tr("Failed to save '%1'").arg(fileName), 5000);
+ }
}
void MainWindow::loadProgess(int percent)