I began debugging the unit to find out why the method combobox is not longer visible for projects loaded later. I added some more DebugLn instructions and got the following message log between loading the project and appearance of the mentioned exception:
Hint: (lazarus) [TMainIDE.DoOpenProjectFile] "D:\Prog_Lazarus\wp-git\jpmMath\fpc\_unittests\jpmTestsGUI.lpi"
*** ENTER OnEditorDestroy ***
[TCodeAnalyzerPlugin] OnEditorDestroy called
*** EXIT OnEditorDestroy ***
******** Highlighter.NeedScan ************
*** ENTER OnEditorActivated ***
*** D:\Prog_Lazarus\wp-git\jpmMath\fpc\_shared\jpmintegration.pas ***
[TCodeAnalyzerPlugin] OnEditorActivated: jpmintegration.pas
*** ENTER UpdateMethods ***
[TCodeAnalyzerPlugin] Updating methods for: jpmintegration.pas
*** ENTER UpdateComboSelection ***
*** CurrentMethodIndex = 2 ***
*** Combobox = $2DBD1F50 ***
*** FCombobox.ClassName = TComboBox ***
*** FCombobox.Items.ClassName = TWin32ComboBoxStringList ***
*** Combobox.Items.Count = 10 ***
[TCodeAnalyzerPlugin] Auto-selected method: GaussIntegral
*** EXIT UpdateComboSelection ***
[TCodeAnalyzerPlugin] UpdateMethods completed. Found 9 methods
*** EXIT UpdateMethods ***
[TCodeAnalyzerPlugin] Cursor change event configured for editor
*** EXIT OnEditorActivated ***
####### ENTER TCombobox.Destroy #######
####### EXIT TCombobox.Destroy #######
*** ENTER OnCursorPosChanged ***
*** FCurrentEditor = 2C8754C0 ***
*** IsValidEditor ***
*** ENTER UpdateComboSelection ***
*** CurrentMethodIndex = 2 ***
*** Combobox = $2DBD1F50 ***
******* FCOMBOBOX IS NOT A CLASS ANY MORE ******
[TCodeAnalyzerPlugin] Error in UpdateComboSelection: Access violation
The issue happens in UpdateComboSelection. It is called two times after loading the project. During the first time, everything is correct, but during the second time the Combobox still has the same address but cannot be detected as a TCustomCombobox class any more. And after adding debuglns also in TCustomCombobox.Create and .Destroy I saw that the combobox is destroyed before the second UpdateComboboxSelection is executed, but not created any more.
The question now is: Why is the combobox destroyed? In your code, it is destroyed only in the DestroyCombo method, but his is not called in this context.
found that the FCombobox class is not longer valid when UpdateComboboxSelection is entered after loading the project. Maybe an external command destroys the editor toolbar, when a new file is loaded, and since the combobox is owned by the toolbar, the toolbar would be destroyed here. Is your plugin notified of such an event?