User forums > Using Code::Blocks
Hiccups while typing (continuation)
ollydbg:
--- Quote from: Pecan on February 04, 2025, 06:23:41 pm ---Another thought might be to issue a shared event to tell all parsers to re-read (update its parser.options) if a user clicks OK in the CodeCompletion settings dialog.
I don't mean to create a new global event, but I know that an event using an XRCID("mySharedEventId") is possible if both sender and receiver use the same XRCID.
--- End quote ---
I can't understand the logic here. But generally, I think this should be done inside the code completion plugin or its base plugin class.
I think the current logic is:
1, When a parser instance becomes "active", its options will be also get active, and "saved to the configure file".
2, When there is NO cbp files opened, a dummy parser(temp parser) will active, it also has its own options.
Case 1:
When you open C::B, the dummy parser is active, when you modify the CC's option, it was modifying the dummy parser's option. When you close C::B, the last active Parser is the dummy parser, so it setting is in the configure file.
Case 2:
You have one cbp(projectA) file opened, and the active parser is the opened cbp. So, when you tweak its CC setting, the option of this parser changed and saved to the configure file. Now, you click the "close button" to close C::B, it just "close the workspace" first. And if all the cbp files get closed, the dummy project parser will set active. You see that when a parser is set active, its option will be saved to the configure file. So, projectA's CC option will be overwritten by the dummy project parser's option to the configure file.
I think the logic here is that every Parser instance could have different options.
EDIT:
I only debugged the above 2 Cases, and I don't debugged other cases, and I can't say much about other cases.
ollydbg:
--- Quote from: Pecan on February 04, 2025, 07:09:03 pm ---@ ollydbg
How about this idea.
The ccoptionsdlg can always record, in a global var, the address of the active parser that last updated the settings.
When the workspace is closed, if that var contains an address, that parser will be the only parser that is allows to update the .conf settings.
That way, any number of projects can be in the workspace, but only the last parser to update the settings can finally store them to the .conf .
Wouldn't that work for only one parser and also for multiple parsers?
If the global var is nullptr, ccoptionsdlg never got called to change any option, then we don't care about which parser updates the .conf .
ccoptionsdlg would only set the active parsers address in the global var, if the user clicked OK to dismiss the dialog.
I'm assuming that the dismiss dialog action (OK or Cancel) can be caught.
Else we'd have to find another way to determine that the user changed any option.
Edit: 10:35am
Got It. void CCOptionsDlg::OnApply() is only called when user clicks OK. I'm thinking that's the only place we need to set the global var with the active parser address.
Is all this true?
--- End quote ---
Some concerns from my mind.
The CC options includes the options from the ccoptionsdlg, but it also includes the options from the classbrowser's GUI.
So, when I see inside the SetParser() function call, it will also save the active classbrowser's GUI setting to the configure file.
Also, if a Parser instance is deleted, the global var (pointer) still point to the deleted memory?
Pecan:
@ ollydbg
Would you try the following CC patch. It works well for me.
It simply remembers the project that applied an options change.
At WriteOptions() it only lets that project update the CC Options and .conf and makes the other projects refresh their cached options.
Patch is also attached to this msg.
--- Code: ---Index: ccoptionsdlg.cpp
===================================================================
--- ccoptionsdlg.cpp (revision 13609)
+++ ccoptionsdlg.cpp (working copy)
@@ -183,6 +183,10 @@
void CCOptionsDlg::OnApply()
{
+ //(ph 2025/02/04) // Set the project that changed the .conf data //(ph 2025/02/04)
+ cbProject* pProject = Manager::Get()->GetProjectManager()->GetActiveProject();
+ m_ParseManager->SetOptsChangerProject(pProject);
+
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
// -----------------------------------------------------------------------
Index: parsemanager.h
===================================================================
--- parsemanager.h (revision 13609)
+++ parsemanager.h (working copy)
@@ -258,6 +258,9 @@
void SetSymbolsWindowHasFocus(bool trueOrFalse){ m_SymbolsWindowHasFocus = trueOrFalse;}
bool GetSymbolsWindowHasFocus(){return m_SymbolsWindowHasFocus;}
+ cbProject* GetOptsChangerProject(){ return m_pOptsChangerProject;} //(ph 2025/02/04)
+ void SetOptsChangerProject(cbProject* pProject){m_pOptsChangerProject = pProject;} //(ph 2025/02/04)
+
protected:
/** When a Parser is created, we need a full parsing stage including:
* 1, parse the priority header files firstly.
@@ -527,6 +530,9 @@
bool m_ClassBrowserViewIsStale = true;
bool m_SymbolsWindowHasFocus = false;
+ //The last project to change the .conf file //(ph 2025/02/04)
+ cbProject* m_pOptsChangerProject = nullptr;
+
};
#endif // PARSEMANAGER_H
Index: parser/parser.cpp
===================================================================
--- parser/parser.cpp (revision 13609)
+++ parser/parser.cpp (working copy)
@@ -29,6 +29,7 @@
#include <wx/tokenzr.h>
#include <cbstyledtextctrl.h>
+#include "..\parsemanager.h" //(ph 2025/02/04)
#include "parser.h"
#include "parserthreadedtask.h"
@@ -921,6 +922,16 @@
void Parser::WriteOptions()
{
+ // If this project didn't change the options, then don't let it overwrite them. //(ph 2025/02/04)
+ cbProject* pActiveProject = Manager::Get()->GetProjectManager()->GetActiveProject();
+ ParseManager* pParseMgr = (ParseManager*)m_Parent;
+ cbProject* pOptsChangerProject = pParseMgr->GetOptsChangerProject();
+ if ( pActiveProject != pOptsChangerProject )
+ {
+ ReadOptions(); // force projects that did not change options to re-read them.
+ return;
+ }
+
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
// Page "Code Completion"
Index: resources/manifest.xml
===================================================================
--- resources/manifest.xml (revision 13609)
+++ resources/manifest.xml (working copy)
@@ -3,7 +3,7 @@
<SdkVersion major="1" minor="10" release="0" />
<Plugin name="CodeCompletion">
<Value title="Code completion" />
- <Value version="1.0.5 24/01/29" />
+ <Value version="1.0.6(ph) 25/02/04" />
<Value description="This plugin provides a symbols browser for your projects and code-completion inside the editor.
--- End code ---
stahta01:
--- Quote from: Pecan on February 05, 2025, 04:38:09 am ---@ ollydbg
Would you try the following CC patch. It works well for me.
It simply remembers the project that applied an options change.
At WriteOptions() it only lets that project update the CC Options and .conf and makes the other projects refresh their cached options.
Patch is also attached to this msg.
--- Code: ---Index: ccoptionsdlg.cpp
===================================================================
--- ccoptionsdlg.cpp (revision 13609)
+++ ccoptionsdlg.cpp (working copy)
@@ -183,6 +183,10 @@
void CCOptionsDlg::OnApply()
{
+ //(ph 2025/02/04) // Set the project that changed the .conf data //(ph 2025/02/04)
+ cbProject* pProject = Manager::Get()->GetProjectManager()->GetActiveProject();
+ m_ParseManager->SetOptsChangerProject(pProject);
+
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
// -----------------------------------------------------------------------
Index: parsemanager.h
===================================================================
--- parsemanager.h (revision 13609)
+++ parsemanager.h (working copy)
@@ -258,6 +258,9 @@
void SetSymbolsWindowHasFocus(bool trueOrFalse){ m_SymbolsWindowHasFocus = trueOrFalse;}
bool GetSymbolsWindowHasFocus(){return m_SymbolsWindowHasFocus;}
+ cbProject* GetOptsChangerProject(){ return m_pOptsChangerProject;} //(ph 2025/02/04)
+ void SetOptsChangerProject(cbProject* pProject){m_pOptsChangerProject = pProject;} //(ph 2025/02/04)
+
protected:
/** When a Parser is created, we need a full parsing stage including:
* 1, parse the priority header files firstly.
@@ -527,6 +530,9 @@
bool m_ClassBrowserViewIsStale = true;
bool m_SymbolsWindowHasFocus = false;
+ //The last project to change the .conf file //(ph 2025/02/04)
+ cbProject* m_pOptsChangerProject = nullptr;
+
};
#endif // PARSEMANAGER_H
Index: parser/parser.cpp
===================================================================
--- parser/parser.cpp (revision 13609)
+++ parser/parser.cpp (working copy)
@@ -29,6 +29,7 @@
#include <wx/tokenzr.h>
#include <cbstyledtextctrl.h>
+#include "..\parsemanager.h" //(ph 2025/02/04)
#include "parser.h"
#include "parserthreadedtask.h"
@@ -921,6 +922,16 @@
void Parser::WriteOptions()
{
+ // If this project didn't change the options, then don't let it overwrite them. //(ph 2025/02/04)
+ cbProject* pActiveProject = Manager::Get()->GetProjectManager()->GetActiveProject();
+ ParseManager* pParseMgr = (ParseManager*)m_Parent;
+ cbProject* pOptsChangerProject = pParseMgr->GetOptsChangerProject();
+ if ( pActiveProject != pOptsChangerProject )
+ {
+ ReadOptions(); // force projects that did not change options to re-read them.
+ return;
+ }
+
ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("code_completion"));
// Page "Code Completion"
Index: resources/manifest.xml
===================================================================
--- resources/manifest.xml (revision 13609)
+++ resources/manifest.xml (working copy)
@@ -3,7 +3,7 @@
<SdkVersion major="1" minor="10" release="0" />
<Plugin name="CodeCompletion">
<Value title="Code completion" />
- <Value version="1.0.5 24/01/29" />
+ <Value version="1.0.6(ph) 25/02/04" />
<Value description="This plugin provides a symbols browser for your projects and code-completion inside the editor.
--- End code ---
--- End quote ---
--- Code: ---#include "..\parsemanager.h"
--- End code ---
My guess is the above line will fail under Linux.
Tim S.
Pecan:
--- Quote from: stahta01 on February 05, 2025, 04:48:06 am ---
--- Code: ---#include "..\parsemanager.h"
--- End code ---
My guess is the above line will fail under Linux.
Tim S.
--- End quote ---
Thanks
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version