diff options
author | Chris Xiong <chirs241097@gmail.com> | 2017-08-10 00:14:44 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2017-08-10 00:14:44 +0800 |
commit | ab33532da11672ee435e2b566cdba81b2e79e874 (patch) | |
tree | b4c9aa59459f5586831384835ced28951e874967 /qmidiplayer-desktop/qmpplugin.cpp | |
parent | b03133b80b268c74d1dd5c92e2af6907b51c91b2 (diff) | |
download | QMidiPlayer-ab33532da11672ee435e2b566cdba81b2e79e874.tar.xz |
Windows of several main functionalities are no longer
QDialogs. Fixed unexpected behavior.
Now visualization window can be closed by sending it
a close signal.
Trying a solution to address the problem that prevents
plugins from being loaded correctly in Windows if the
path contains Chinese characters. Not even tried to
build in Windows though.
Diffstat (limited to 'qmidiplayer-desktop/qmpplugin.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 2cafa7f..6eca257 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -13,32 +13,39 @@ qmpPluginAPI* pluginAPI; qmpMainWindow* qmw; qmpSettingsWindow* qsw; #ifdef _WIN32 +#include <codecvt> +#include <locale> +std::string wstr2str(std::wstring s) +{ + std::wstring_convert<std::codecvt_utf8<wchar_t>,wchat_t> wsc; + return wsc.to_bytes(s); +} void qmpPluginManager::scanPlugins() { QDirIterator *dir; - std::vector<std::string> cpluginpaths; + std::vector<std::wstring> cpluginpaths; dir=new QDirIterator(QCoreApplication::applicationDirPath()+"/plugins/"); while(dir->hasNext()) { dir->next(); if(dir->fileInfo().suffix()=="dll") - cpluginpaths.push_back(QCoreApplication::applicationDirPath().toStdString()+std::string("/plugins/")+dir->fileName().toStdString()); + cpluginpaths.push_back(QCoreApplication::applicationDirPath().toStdWString()+std::wstring(L"/plugins/")+dir->fileName().toStdWString()); } delete dir; for(unsigned i=0;i<cpluginpaths.size();++i) { - HMODULE hso=LoadLibraryA(cpluginpaths[i].c_str()); + HMODULE hso=LoadLibraryW(cpluginpaths[i].c_str()); if(!hso){fprintf(stderr,"Error while loading library: %d\n",GetLastError());continue;} FARPROC hndi=GetProcAddress(hso,"qmpPluginGetInterface"); - if(!hndi){fprintf(stderr,"file %s doesn't seem to be a qmidiplayer plugin.\n",cpluginpaths[i].c_str());continue;} + if(!hndi){fprintf(stderr,"plugin %s doesn't seem to be a qmidiplayer plugin.\n",wstr2str(cpluginpaths[i]).c_str());continue;} FARPROC hndiv=GetProcAddress(hso,"qmpPluginGetAPIRev"); - if(!hndiv){fprintf(stderr,"file %s is incompatible with this version of qmidiplayer.\n",cpluginpaths[i].c_str());continue;} + if(!hndiv){fprintf(stderr,"plugin %s is incompatible with this version of qmidiplayer.\n",wstr2str(cpluginpaths[i]).c_str());continue;} qmpPluginAPIRevEntry getv=(qmpPluginAPIRevEntry)hndiv; if(strcmp(getv(),QMP_PLUGIN_API_REV)) - {fprintf(stderr,"file %s is incompatible with this version of qmidiplayer.\n",cpluginpaths[i].c_str());continue;} + {fprintf(stderr,"plugin %s is incompatible with this version of qmidiplayer.\n",wstr2str(cpluginpaths[i]).c_str());continue;} qmpPluginEntry e=(qmpPluginEntry)hndi; qmpPluginIntf* intf=e(pluginAPI); - plugins.push_back(qmpPlugin(std::string(intf->pluginGetName()),std::string(intf->pluginGetVersion()),std::string(cpluginpaths[i]),intf)); + plugins.push_back(qmpPlugin(std::string(intf->pluginGetName()),std::string(intf->pluginGetVersion()),wstr2str(cpluginpaths[i]),intf)); } } #else |