User forums > Nightly builds

The 21 June 2016 build (10868) is out.

<< < (5/9) > >>

Pecan:
Corrected patch.
Comparison on m_ProjectFilename was incorrect.



--- Code: ---Index: src/sdk/macrosmanager.cpp
===================================================================
--- src/sdk/macrosmanager.cpp (revision 10889)
+++ src/sdk/macrosmanager.cpp (working copy)
@@ -269,7 +269,10 @@
         m_Macros[_T("MAKEFILE")]             = wxEmptyString;
         m_Macros[_T("ALL_PROJECT_FILES")]    = wxEmptyString;
     }
-    else if (project != m_LastProject)
+    else if ( (project != m_LastProject) || (project->GetTitle() != m_ProjectName)
+                || (UnixFilename(project->GetBasePath()) != m_ProjectDir)
+                || (UnixFilename(m_ProjectWxFileName.GetFullName()) != m_ProjectFilename)
+             )
     {
         m_LastTarget      = nullptr; // reset last target when project changes
         m_ProjectWxFileName.Assign(project->GetFilename());
@@ -340,7 +343,7 @@
         m_TargetFilename       = wxEmptyString;
         m_LastTarget           = nullptr;
     }
-    else if (target != m_LastTarget)
+    else if ( (target != m_LastTarget) or (target->GetTitle() != m_TargetName) )
     {
         wxFileName tod(target->GetOutputFilename());
         m_TargetOutputDir      = UnixFilename(tod.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
@@ -455,7 +458,10 @@
                 target = project->GetBuildTarget(project->GetActiveBuildTarget());
         }
     }
-    if (project != m_LastProject || target != m_LastTarget || (editor && (editor->GetFilename() != m_ActiveEditorFilename)) )
+    if (project != m_LastProject || target != m_LastTarget || (editor && (editor->GetFilename() != m_ActiveEditorFilename))
+                    || (project && (UnixFilename(project->GetBasePath()) != m_ProjectDir))
+                    || (UnixFilename(m_ProjectWxFileName.GetFullName()) != m_ProjectFilename)
+                    || (target && (target->GetTitle() != m_TargetName)) )
         RecalcVars(project, editor, target);
 
     wxString search;

--- End code ---

oBFusCATed:
Why don't you detect project close event and set the m_lastproject to null?

Pecan:

--- Quote from: oBFusCATed on August 02, 2016, 03:56:35 am ---Why don't you detect project close event and set the m_lastproject to null?

--- End quote ---

cbEvent_Project_Closed is not called during the compilation of a workspace.
The macros have to be reset before compilation of a project in a workspace.

I'll try working with WorkSpaceChanged() event. But macrosmanager get called in so many places outside of events..... the conditions are mind boggling.

oBFusCATed:
You can leave the pointer comparison probably, just make sure that the pointer is reset when there is no project loaded. Everything else should probably stay the same.

Pecan:

--- Quote from: oBFusCATed on August 02, 2016, 09:01:37 pm ---You can leave the pointer comparison probably, just make sure that the pointer is reset when there is no project loaded. Everything else should probably stay the same.

--- End quote ---

I have spent hours trapping events, hoping to find one that could be used to reliably reset the old project pointer in macros manager. 

Unfortunately, there is no CB event that can be used to reliably reset the last project pointer to zero when multiple projects exist within a workspace and the user does a full workspace build.

The pointer must be reset between compiles of projects within a workspace as well as project activation, open and close.

The compiler events can be used to reset the pointer just before a compile, but these events are (erroneously) invoked by the CodeCompletion plugin so many times it's a turkey shoot to figure out if it's a CodeCompletion call or a real request for compilation. The current comparisons are less overhead then resetting the project pointer for erroneous compilation events.

Using complilation events would also miss the needed project events reset.

The current patch is the only method I can find to reliably reset the old project pointer for both api macro translation calls (cb core, plugins, scripts, etc) and which catch all events that require macro translation.

I welcome further suggestions.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version