Predelnik / DSpellCheck

Notepad++ Spell-checking Plug-in
GNU General Public License v2.0
198 stars 32 forks source link

Compatibilty with other plugins written in Delphi #311

Open chcg opened 1 year ago

chcg commented 1 year ago

See analysis for https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4427

After removing all plug-ins and adding them back in one-by-one I found that Zoom Disabler 1.2 is causing this same error.

You're on the right track. The underlying problem is that DSpellCheck does not play nice with plugins coded in Delphi1, like Zoom Disabler and the — https://github.com/Predelnik/DSpellCheck/issues/173#issuecomment-593865625 — ExtSettings plugin.

Delphi plugins implicitly call into COM libraries to create and destroy dialog windows. DSpellCheck makes explicit calls to the same functions, against the advice of Microsoft to never call them from the context of DllMain,

[b]ecause there is no way to control the order in which in-process servers are loaded or unloaded

DSpellCheck invalidates the Delphi plugin's own de-initialization by releasing the same resources first. Footnotes

rdipardo commented 1 year ago

See analysis for https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4427

My thinking has changed since that earlier post; see https://github.com/StanDog/npp-zoomdisabler/issues/3#issuecomment-1422440770

Predelnik commented 1 year ago

I don't think it's correct statement that CoUninitialize is called inside DllMain in DSpellCheck, particularly NativeSpellerInterface::cleanup is called on NPPN_SHUTDOWN. There is also another call during browse for directory but this one probably irrelevant and could be removed.

I think what I can do is to never call CoInitialize/CoUninitialize unless native speller is used, that would probably make it ok for most of the cases.