Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

cbEVT_COMPILER_FINISHED

(1/3) > >>

Picardo:
Good day,

Is there a better way to determine when a user requested a build than using a cbEVT_COMPILER_FINISHED event? I use this event to trigger execution of other code and it works well but when a user selects Build and Run, the cbEVT_COMPILER_FINISHED fires twice. This causes the other code to run twice, which is not what I want. 

oBFusCATed:
Can you describe what you want to achieve in more details?

Picardo:
Hi oBFusCATed, thanks for your reply. 

I want to save a copy of the source code and build log of student programmers as it is at compile time. The (secretly) saved copies will then be analysed to determine what the students are struggling with.

The plugin as it is works well except that it saves two copies of the same info if the Build and Run command is used. I have thought of checking the time between compiles to determine if the save function should run or not but it feels a bit like a workaround. Any suggestions?

oBFusCATed:
I've done some debugging and it seems the second event is sent when the run application is closed. So an event is sent even when only running an application. This is definitely a bug, but I'm not sure how hard it would be to fix it.

oBFusCATed:
Can you try this patch and let me know if there are some strange behaviours:


--- Code: ---diff --git a/src/plugins/compilergcc/compilergcc.cpp b/src/plugins/compilergcc/compilergcc.cpp
index 73705184d..0d13c96fa 100644
--- a/src/plugins/compilergcc/compilergcc.cpp
+++ b/src/plugins/compilergcc/compilergcc.cpp
@@ -3931,10 +3931,12 @@ void CompilerGCC::NotifyJobDone(bool showNothingToBeDone)
         ProjectManager *manager = Manager::Get()->GetProjectManager();
         if (manager->GetIsRunning() == this)
             manager->SetIsRunning(NULL);
-
-        CodeBlocksEvent evt(cbEVT_COMPILER_FINISHED, 0, m_pProject, 0, this);
-        evt.SetInt(m_LastExitCode);
-        Manager::Get()->ProcessEvent(evt);
+        else
+        {
+            CodeBlocksEvent evt(cbEVT_COMPILER_FINISHED, 0, m_pProject, 0, this);
+            evt.SetInt(m_LastExitCode);
+            Manager::Get()->ProcessEvent(evt);
+        }
         m_LastExitCode = 0;
     }
 }

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version