Revert "qtplugins"

This reverts commit 6834f6809d.
This commit is contained in:
恍兮惚兮 2024-03-28 19:26:32 +08:00
parent 6e011c5780
commit 7518d4a8eb
2 changed files with 26 additions and 4 deletions

View File

@ -4,7 +4,7 @@ target_precompile_headers(ToClipboard REUSE_FROM pch)
set_target_properties(ToClipboard PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugin${bitappendix}")
endif()
if(0) #pluginmanager->QtLoadLibrarys
include(QtUtils.cmake)
msvc_registry_search()
if(Qt5_DIR)
@ -15,5 +15,4 @@ if(Qt5_DIR)
#target_sources(QtLoader PRIVATE ${MOC_SOURCES})
target_link_libraries(QtLoader Qt5::Widgets Qt5::Core)
set_target_properties(QtLoader PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugin${bitappendix}")
endif()
endif()

View File

@ -108,6 +108,14 @@ std::vector<HMODULE> QtLoadLibrarys(std::vector<std::wstring>&collectQtplugs)
return modules;
}
typedef HMODULE*(*QtLoadLibrary_t)(LPWSTR*,int);
QtLoadLibrary_t loadqtloader(const std::filesystem::path&pluginpath){
auto QtLoaderPath=pluginpath/"QtLoader.dll";
auto helper=LoadLibrary(QtLoaderPath.c_str());
if(helper==0)return 0;
auto QtLoadLibrary = (QtLoadLibrary_t)GetProcAddress(helper, "QtLoadLibrary");
return QtLoadLibrary;
}
void Pluginmanager::loadqtdlls(std::vector<std::wstring>&collectQtplugs){
if(collectQtplugs.size()==0)return;
auto pluginpath=std::filesystem::current_path()/(x64?"plugin64":"plugin32");
@ -120,9 +128,24 @@ void Pluginmanager::loadqtdlls(std::vector<std::wstring>&collectQtplugs){
}
SetEnvironmentVariableW(L"PATH",envs.c_str());
auto modules=QtLoadLibrarys(collectQtplugs);
if(modules.empty())return;
// auto modules=QtLoadLibrarys(collectQtplugs);
// if(modules.empty())return;
auto QtLoadLibrary = loadqtloader(pluginpath);
if(!QtLoadLibrary){
MessageBoxW(host->winId,CantLoadQtLoader,L"Error",0);
return ;
}
std::vector<wchar_t*>saves;
for(auto&p:collectQtplugs){
auto str=new wchar_t[p.size()+1];
wcscpy(str,p.c_str());
saves.emplace_back(str);
}
auto modules=QtLoadLibrary(saves.data(),collectQtplugs.size());
for(auto str:saves)delete str;
for(int i=0;i<collectQtplugs.size();i++){
OnNewSentenceS[collectQtplugs[i]]=GetProcAddress(modules[i],"OnNewSentence");
}