qmlFrontend/hwengine.cpp
branchqmlfrontend
changeset 10426 727a154cf784
parent 10424 4be6cd55f1cf
child 10428 7c25297720f1
--- a/qmlFrontend/hwengine.cpp	Sat Sep 27 12:49:08 2014 +0400
+++ b/qmlFrontend/hwengine.cpp	Sun Sep 28 00:18:01 2014 +0400
@@ -9,7 +9,7 @@
 
 extern "C" {
     RunEngine_t *RunEngine;
-    registerIPCCallback_t *registerIPCCallback;
+    registerPreviewCallback_t *registerPreviewCallback;
     ipcToEngine_t *ipcToEngine;
     flibInit_t *flibInit;
     flibFree_t *flibFree;
@@ -25,13 +25,13 @@
         qWarning() << "Engine library not found" << hwlib.errorString();
 
     RunEngine = (RunEngine_t*) hwlib.resolve("RunEngine");
-    registerIPCCallback = (registerIPCCallback_t*) hwlib.resolve("registerIPCCallback");
+    registerPreviewCallback = (registerPreviewCallback_t*) hwlib.resolve("registerIPCCallback");
     ipcToEngine = (ipcToEngine_t*) hwlib.resolve("ipcToEngine");
     flibInit = (flibInit_t*) hwlib.resolve("flibInit");
     flibFree = (flibFree_t*) hwlib.resolve("flibFree");
 
     flibInit(".", "~/.hedgewars");
-    registerIPCCallback(this, &engineMessageCallback);
+    registerPreviewCallback(this, &enginePreviewCallback);
 }
 
 HWEngine::~HWEngine()
@@ -80,7 +80,7 @@
     ipcToEngine(b.constData(), len);
 }
 
-void HWEngine::engineMessageCallback(void *context, const char * msg, quint32 len)
+void HWEngine::enginePreviewCallback(void *context, const char * msg, quint32 len)
 {
     HWEngine * obj = (HWEngine *)context;
     QByteArray b = QByteArray::fromRawData(msg, len);
@@ -92,9 +92,12 @@
 
 void HWEngine::engineMessageHandler(const QByteArray &msg)
 {
-    PreviewImageProvider * preview = (PreviewImageProvider *)m_engine->imageProvider(QLatin1String("preview"));
-    preview->setPixmap(msg);
-    emit previewImageChanged();
+    if(msg.size() == 128 * 256)
+    {
+        PreviewImageProvider * preview = (PreviewImageProvider *)m_engine->imageProvider(QLatin1String("preview"));
+        preview->setPixmap(msg);
+        emit previewImageChanged();
+    }
 }
 
 QString HWEngine::currentSeed()