Author Topic: The 21 June 2016 build (10868) is out.  (Read 20440 times)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2066
Re: The 21 June 2016 build (10868) is out.
« Reply #15 on: July 25, 2016, 09:09:30 pm »
When a workspace with only one project is closed, then another loaded, it's possible for the newly loaded project to be assigned the same memory address as the closed project.

Thus, any test against the previously loaded projects address will match, and macrosmanager.cpp will not replace the macros for the second project.
 
Below is the fix. I'll apply after review by other team members.
 
Code: [Select]
Index: src/sdk/macrosmanager.cpp
===================================================================
--- src/sdk/macrosmanager.cpp (revision 10889)
+++ src/sdk/macrosmanager.cpp (working copy)
@@ -269,7 +269,7 @@
         m_Macros[_T("MAKEFILE")]             = wxEmptyString;
         m_Macros[_T("ALL_PROJECT_FILES")]    = wxEmptyString;
     }
-    else if (project != m_LastProject)
+    else if ( (project != m_LastProject) or (project->GetTitle() != m_ProjectName) )
     {
         m_LastTarget      = nullptr; // reset last target when project changes
         m_ProjectWxFileName.Assign(project->GetFilename());
@@ -340,7 +340,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 +455,8 @@
                 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 && (project->GetTitle() != m_ProjectName)) || (target && (target->GetTitle() != m_TargetName)) )
         RecalcVars(project, editor, target);
 
     wxString search;

Offline blauzahn

  • Multiple posting newcomer
  • *
  • Posts: 59
Re: The 21 June 2016 build (10868) is out.
« Reply #16 on: July 26, 2016, 06:37:55 am »
What if the checked attributes of the 2 projects are the same? This is quite probable when
you load a different version of the same project (e.g. a backup). Ideally, the
solution does not depend on any attribute at all. Would it make sense to set
m_LastProject to nullptr on close or would that contradict its purpose?

Until then, I welcome an improvement like yours.


Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2066
Re: The 21 June 2016 build (10868) is out.
« Reply #17 on: July 26, 2016, 06:48:02 pm »
What if the checked attributes of the 2 projects are the same? ...

Good point.
So, we need a unique attribute.

Question: Is it always true that the absolute form of the project filename (.cbp) is unique for all projects?


Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2066
Re: The 21 June 2016 build (10868) is out.
« Reply #18 on: July 27, 2016, 06:54:43 pm »
What if the checked attributes of the 2 projects are the same?

New patch to assure that the secondary attribute comparison is unique.
Also using the shorter comparisons first as a short circuit to the result.

Code: [Select]
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(project->GetFilename()) != 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))
+            || (project && (UnixFilename(project->GetFilename()) != m_ProjectFilename))
+            || (target && (target->GetTitle() != m_TargetName)) )
         RecalcVars(project, editor, target);
 
     wxString search;

Offline Oleg_Sam

  • Multiple posting newcomer
  • *
  • Posts: 28
Re: The 21 June 2016 build (10868) is out.
« Reply #19 on: July 29, 2016, 12:40:43 pm »
Thank you for this patch. Now its all work fine!

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2066
Re: The 21 June 2016 build (10868) is out.
« Reply #20 on: July 31, 2016, 12:20:10 am »
Corrected patch.
Comparison on m_ProjectFilename was incorrect.


Code: [Select]
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;

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: The 21 June 2016 build (10868) is out.
« Reply #21 on: August 02, 2016, 03:56:35 am »
Why don't you detect project close event and set the m_lastproject to null?
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2066
Re: The 21 June 2016 build (10868) is out.
« Reply #22 on: August 02, 2016, 07:49:55 pm »
Why don't you detect project close event and set the m_lastproject to null?

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.
« Last Edit: August 02, 2016, 07:56:31 pm by Pecan »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: The 21 June 2016 build (10868) is out.
« Reply #23 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.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2066
Re: The 21 June 2016 build (10868) is out.
« Reply #24 on: August 03, 2016, 05:30:04 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.

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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: The 21 June 2016 build (10868) is out.
« Reply #25 on: August 03, 2016, 09:10:00 pm »
The current comparisons are less overhead then resetting the project pointer for erroneous compilation events.
I'm concerned about the robustness and not the performance. I'll give it a try hopefully soon.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Andy356

  • Single posting newcomer
  • *
  • Posts: 8
Re: The 21 June 2016 build (10868) is out.
« Reply #26 on: August 11, 2016, 06:18:02 pm »
Hi guys,

I just noticed that -std=c11 is not available as a standard compiler flag. It's trivial to enable it in "Other compiler options", or add it as a new flag, but still, it should be a flag provided by default...

Edit: The compiler is GCC 6.1. The man page lists c11 as a valid flag. (Thanks, stahta01)
« Last Edit: August 12, 2016, 12:06:30 am by Andy356 »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5870
    • My Best Post
Re: The 21 June 2016 build (10868) is out.
« Reply #27 on: August 11, 2016, 07:13:22 pm »
FYI: Compiler flags are per compiler; you should state which compiler is missing the option that needs it.

Hi guys,

I just noticed that -std=c11 is not available as a standard compiler flag. It's trivial to enable it in "Other compiler options", or add it as a new flag, but still, it should be a flag provided by default...
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline pcoquill

  • Single posting newcomer
  • *
  • Posts: 4
Re: The 21 June 2016 build (10868) is out.
« Reply #28 on: August 24, 2016, 12:51:25 pm »
Hi,
My antivirus (AVG) indicates the presence of a trojan virus in one dll: Inject3.AVPH.
Any information about this ?

Regards, Patrick

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7191
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: The 21 June 2016 build (10868) is out.
« Reply #29 on: August 24, 2016, 10:37:21 pm »
Hi,
My antivirus (AVG) indicates the presence of a trojan virus in one dll: Inject3.AVPH.
Any information about this ?

Regards, Patrick
Most likely a false positive (not the first one).

You should test it on http://virustotal.com .