Переглянути джерело

Create temporary file for secondary capture

Ivo Wolf 13 роки тому
батько
коміт
d0b70917c8

+ 12 - 2
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic.cpp

@@ -156,6 +156,7 @@ void ctkExampleDicomAppLogic::onExitHostedApp()
   //useless move, but correct:
   setInternalState(ctkDicomAppHosting::EXIT);
   getHostInterface()->notifyStateChanged(ctkDicomAppHosting::EXIT);
+  qDebug() << "Exiting";
   //die
   qApp->exit(0);
 }
@@ -262,8 +263,17 @@ void ctkExampleDicomAppLogic::onCreateSecondaryCapture()
   const QPixmap* pixmap = ui.PlaceHolderForImage->pixmap();
   if(pixmap!=NULL)
   {
-    tempfile = new QTemporaryFile(this->AppWidget);
-    pixmap->save(tempfile.fileName(), "PNG");
+    QTemporaryFile *tempfile = new QTemporaryFile("ctkdahscXXXXXX.png",this->AppWidget);
+    QString filename;
+    if(tempfile->open())
+    {
+      filename = QFileInfo(tempfile->fileName()).absoluteFilePath();
+      qDebug() << "Created file: " << filename;
+      tempfile->close();
+      pixmap->save(tempfile->fileName(), "PNG");
+    }
+    else
+      qDebug() << "Creating temporary file failed.";
   }
 
 }