Fix a ton of bugs in engine instances queue and ipc qmlfrontend
authorunc0rr
Thu, 17 Dec 2015 00:51:20 +0300
branchqmlfrontend
changeset 11464 30397f91571c
parent 11463 8318e841648f
child 11465 9f2fb0031ef0
Fix a ton of bugs in engine instances queue and ipc
hedgewars/uFLIPC.pas
hedgewars/uFLRunQueue.pas
--- a/hedgewars/uFLIPC.pas	Wed Dec 16 00:20:56 2015 +0300
+++ b/hedgewars/uFLIPC.pas	Thu Dec 17 00:51:20 2015 +0300
@@ -41,7 +41,7 @@
     s.next:= nil;
     s.barrier:= 0;
 
-    if (queue^.msg.next = nil) and (queue^.msg.str[0] = #0) and (queue^.msg.buf = nil) then
+    if (queue^.msg.next = nil) and (queue^.msg.str[0] = #0) and (queue^.msg.buf = nil) and (queue^.msg.barrier = 0) then
     begin
         queue^.msg:= s;
     end else
@@ -129,15 +129,19 @@
     SDL_LockMutex(q^.mut);
 
     pmsg:= @q^.msg;
-    q^.last:= @q^.msg;
-
+write('    ipcRemoveBarrierFromEngineQueue: ');
     while pmsg <> nil do
     begin
+        write('.');
         t:= pmsg^.next;
         q^.msg.next:= t;
 
+        pmsg^.str[0]:= #0;
         if pmsg^.buf <> nil then
+        begin
             FreeMem(pmsg^.buf, pmsg^.len);
+            pmsg^.buf:= nil
+        end;
 
         if pmsg <> @q^.msg then
             if pmsg^.barrier = 0 then
@@ -162,6 +166,8 @@
 
         pmsg:= t
     end;
+writeln;
+    if q^.msg.next = nil then q^.last:= @q^.msg;
 
     q^.msg.str[0]:= #0;
     q^.msg.buf:= nil;
--- a/hedgewars/uFLRunQueue.pas	Wed Dec 16 00:20:56 2015 +0300
+++ b/hedgewars/uFLRunQueue.pas	Thu Dec 17 00:51:20 2015 +0300
@@ -14,13 +14,12 @@
 begin
     if runQueue <> nil then
     begin
+    writeln('RUNNING ', runQueue^.gameType);
         if runQueue^.gameType = gtPreview then
             sendUI(mtRenderingPreview, nil, 0);
 
         ipcRemoveBarrierFromEngineQueue();
         RunEngine(runQueue^.argumentsNumber, @runQueue^.argv);
-
-        sendConfig(runQueue)
     end
 end;
 
@@ -36,8 +35,7 @@
 var pConfig, t, tt: PGameConfig;
     i: Longword;
 begin
-    ipcSetEngineBarrier();
-
+    writeln('QUEUE EXECUTION ', config.gameType);
     new(pConfig);
     pConfig^:= config;
 
@@ -59,13 +57,15 @@
     begin
         runQueue:= pConfig;
 
+        ipcSetEngineBarrier();
+        sendConfig(pConfig);
         nextRun
     end else
     begin
         t:= runQueue;
         while t^.nextConfig <> nil do 
         begin
-            if (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) then
+            if false and (pConfig^.gameType = gtPreview) and (t^.nextConfig^.gameType = gtPreview) and (t <> runQueue) then
             begin
                 tt:= t^.nextConfig;
                 pConfig^.nextConfig:= tt^.nextConfig;
@@ -75,6 +75,9 @@
             end;
             t:= t^.nextConfig;
         end;
+
+        ipcSetEngineBarrier();
+        sendConfig(pConfig);
         t^.nextConfig:= pConfig
     end;
 end;