From e7e686c3619dd16eafc7d780facf3de5c079f189 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 18 Aug 2014 23:00:25 +0200 Subject: [PATCH 01/10] - can now filter by mod content - all files/directories that require write access can now be placed in AppData instead of the MO directory --- src/proxy/proxypython.cpp | 1 + src/runner/uibasewrappers.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/proxy/proxypython.cpp b/src/proxy/proxypython.cpp index 5d72e29..0ed3b4b 100644 --- a/src/proxy/proxypython.cpp +++ b/src/proxy/proxypython.cpp @@ -73,6 +73,7 @@ QString ExtractResource(WORD resourceID, const QString &szFilename) UnmapViewOfFile(lpAddress); CloseHandle(hFileMap); + ::FlushFileBuffers(hFile); CloseHandle(hFile); return outFile; diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index af25b6d..cbfcc39 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -220,6 +220,7 @@ struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapperget_override("resolvePath")(fileName); } virtual QStringList listDirectories(const QString &directoryName) const { return this->get_override("listDirectories")(directoryName); } virtual QStringList findFiles(const QString &path, const std::function &filter) const { return this->get_override("findFiles")(path, filter); } + virtual QStringList getFileOrigins(const QString &fileName) const { return this->get_override("getFileOrigins")(fileName); } virtual QList findFileInfos(const QString &path, const std::function &filter) const { return this->get_override("findFileInfos")(path, filter); } virtual HANDLE startApplication(const QString &executable, const QStringList &args = QStringList(), const QString &cwd = "", const QString &profile = "") { return this->get_override("startApplication")(executable, args, cwd, profile); } virtual bool waitForApplication(HANDLE handle, LPDWORD exitCode = NULL) const { return this->get_override("waitForApplication")(handle, exitCode); } From 84fe2b0307b4dcc21880e2ae629e09b6ae218743 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 8 Sep 2014 20:37:23 +0200 Subject: [PATCH 02/10] - re-enabled building of loot_cli and started developing against the new api - extended set of default categories - more tolerand bbcode parser - added a few colors for the bbcode parser - more fixes to qt5 compatibility - started work on ability to unloading (and thus re-loading) of plugins - names of plugins are no longer localizable (because those names are also used to store settings) - added settings to disable individual diagnosis settings - path of dependencies is now configured in a .pri file instead of environment variablees - bugfix: if the modid-input is canceled, the id was saved as -1 and wasn't re-requested from the user - bugfix: moving files with the SHFileOperation-Api didn't update the vfs correctly (still not perfect but better) - bugfix: attempt to remove the deleter-file seems to have caused error messages for some users - bugfix: fixed a couple of cases that might have caused the tutorial to hang --- src/proxy/proxyPython.pro | 2 +- src/proxy/proxypython.cpp | 2 +- src/runner/error.cpp | 2 ++ src/runner/proxypluginwrappers.h | 1 - src/runner/pythonRunner.pro | 12 +++++++++--- src/runner/pythonrunner.cpp | 1 - 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/proxy/proxyPython.pro b/src/proxy/proxyPython.pro index c8cc51f..eaa3614 100644 --- a/src/proxy/proxyPython.pro +++ b/src/proxy/proxyPython.pro @@ -36,7 +36,7 @@ RC_FILE += \ include(../plugin_template.pri) -INCLUDEPATH += "../../pythonRunner" "$(BOOSTPATH)" +INCLUDEPATH += "../../pythonRunner" "$${BOOSTPATH}" WINPWD = $$PWD WINPWD ~= s,/,$$QMAKE_DIR_SEP,g diff --git a/src/proxy/proxypython.cpp b/src/proxy/proxypython.cpp index 0ed3b4b..2592b7f 100644 --- a/src/proxy/proxypython.cpp +++ b/src/proxy/proxypython.cpp @@ -164,7 +164,7 @@ bool ProxyPython::init(IOrganizer *moInfo) QString ProxyPython::name() const { - return tr("Python Proxy"); + return "Python Proxy"; } QString ProxyPython::author() const diff --git a/src/runner/error.cpp b/src/runner/error.cpp index a1ae993..62a2346 100644 --- a/src/runner/error.cpp +++ b/src/runner/error.cpp @@ -1,4 +1,6 @@ +#ifndef Q_MOC_RUN #include +#endif #include #include diff --git a/src/runner/proxypluginwrappers.h b/src/runner/proxypluginwrappers.h index 49e87df..089ce35 100644 --- a/src/runner/proxypluginwrappers.h +++ b/src/runner/proxypluginwrappers.h @@ -5,7 +5,6 @@ #include #include #include -#include #ifndef Q_MOC_RUN #include diff --git a/src/runner/pythonRunner.pro b/src/runner/pythonRunner.pro index aa11767..dbffac8 100644 --- a/src/runner/pythonRunner.pro +++ b/src/runner/pythonRunner.pro @@ -13,7 +13,13 @@ CONFIG += warn_on DEFINES += PYTHONRUNNER_LIBRARY # suppress a few warnings caused by boost vs vc++ paranoia -DEFINES += _SCL_SECURE_NO_WARNINGS +DEFINES += _SCL_SECURE_NO_WARNINGS -DHAVE_ROUND + + +!include(../LocalPaths.pri) { + message("paths to required libraries need to be set up in LocalPaths.pri") +} + SOURCES += pythonrunner.cpp \ gilock.cpp \ @@ -36,8 +42,8 @@ CONFIG(debug, debug|release) { QMAKE_LFLAGS += /DEBUG } -INCLUDEPATH += "$(BOOSTPATH)" "$$(PYTHONPATH)/include" "$$(PYTHONPATH)/Lib/site-packages/PyQt4/include" -LIBS += -L"$$(PYTHONPATH)/libs" -L"$(BOOSTPATH)/stage/lib" +INCLUDEPATH += "$${BOOSTPATH}" "$${PYTHONPATH}/include" "$${PYTHONPATH}/Lib/site-packages/PyQt4/include" +LIBS += -L"$${PYTHONPATH}/libs" -L"$${BOOSTPATH}/stage/lib" LIBS += -lpython27 INCLUDEPATH += ../uibase diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 8c5760c..d79a695 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -5,7 +5,6 @@ #pragma warning( disable : 4100 ) #pragma warning( disable : 4996 ) -#include #include #include "uibasewrappers.h" #include "pythonpluginwrapper.h" From fa09fd76356c965127d8f216f88ab39b8159f0d7 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 10 Sep 2014 20:37:17 +0200 Subject: [PATCH 03/10] plugins can now query the list of masters for a plugin --- src/runner/pythonrunner.cpp | 2 ++ src/runner/uibasewrappers.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index d79a695..719981c 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -725,6 +725,7 @@ BOOST_PYTHON_MODULE(mobase) .def("pluginList", bpy::pure_virtual(&IOrganizer::pluginList), bpy::return_value_policy()) .def("modList", bpy::pure_virtual(&IOrganizer::modList), bpy::return_value_policy()) .def("startApplication", bpy::pure_virtual(&IOrganizer::startApplication), bpy::return_value_policy()) + .def("waitForApplication", bpy::pure_virtual(&IOrganizer::waitForApplication), bpy::return_value_policy()) .def("onAboutToRun", bpy::pure_virtual(&IOrganizer::onAboutToRun)) .def("onModInstalled", bpy::pure_virtual(&IOrganizer::onModInstalled)) .def("refreshModList", bpy::pure_virtual(&IOrganizer::refreshModList)) @@ -804,6 +805,7 @@ BOOST_PYTHON_MODULE(mobase) .def("priority", bpy::pure_virtual(&MOBase::IPluginList::priority)) .def("loadOrder", bpy::pure_virtual(&MOBase::IPluginList::loadOrder)) .def("isMaster", bpy::pure_virtual(&MOBase::IPluginList::isMaster)) + .def("masters", bpy::pure_virtual(&MOBase::IPluginList::masters)) .def("origin", bpy::pure_virtual(&MOBase::IPluginList::origin)) .def("onRefreshed", bpy::pure_virtual(&MOBase::IPluginList::onRefreshed)) .def("onPluginMoved", bpy::pure_virtual(&MOBase::IPluginList::onPluginMoved)) diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index cbfcc39..354346a 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -278,6 +278,7 @@ struct IPluginListWrapper: MOBase::IPluginList, boost::python::wrapperget_override("priority")(name); } virtual int loadOrder(const QString &name) const { return this->get_override("loadOrder")(name); } virtual bool isMaster(const QString &name) const { return this->get_override("isMaster")(name); } + virtual QStringList masters(const QString &name) const { return this->get_override("masters")(name); } virtual QString origin(const QString &name) const { return this->get_override("origin")(name); } virtual bool onRefreshed(const std::function &callback) { return this->get_override("onRefreshed")(callback); } virtual bool onPluginMoved(const std::function &callback) { return this->get_override("onPluginMoved")(callback); } From 2c661da2da200225b0aba958cbfaa7349c071955 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 29 Sep 2014 20:35:35 +0200 Subject: [PATCH 04/10] - moved the hook-recursion-protection to tls - some code cleanup and consolidation - hook.dll will now report all of its own exceptions - some more logging during startup - changed the way urls are encoded for download requests - now displaying (one of the) process name(s) while waiting for a program to end - bugfix: spawned processes were forced to leave the job --- src/proxy/proxyPython.pro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/proxy/proxyPython.pro b/src/proxy/proxyPython.pro index eaa3614..f1a0f86 100644 --- a/src/proxy/proxyPython.pro +++ b/src/proxy/proxyPython.pro @@ -41,9 +41,9 @@ INCLUDEPATH += "../../pythonRunner" "$${BOOSTPATH}" WINPWD = $$PWD WINPWD ~= s,/,$$QMAKE_DIR_SEP,g -//QMAKE_POST_LINK += SET VS90COMNTOOLS=%VS100COMNTOOLS% $$escape_expand(\\n) +#QMAKE_POST_LINK += SET VS90COMNTOOLS=%VS100COMNTOOLS% $$escape_expand(\\n) -//QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\sip.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n) -//QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtCore.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n) -//QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n) +#QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\sip.pyd $$quote($$DSTDIR)\\plugins\\data\\ $$escape_expand(\\n) +#QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtCore.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n) +#QMAKE_POST_LINK += copy $$(PYTHONPATH)\\lib\\site-packages\\PyQt4\\QtGui.pyd $$quote($$DSTDIR)\\plugins\\data\\PyQt4\\ $$escape_expand(\\n) From 573be8c6b5b782ea479a76906456aa9a4174dd56 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 9 Nov 2014 14:01:48 +0100 Subject: [PATCH 05/10] - bsa parser will now cancel in case of a read error. Before, when attempting to parse a broken bsa it could take forever and continuously allocate memory - better error message when bsa parsing fails - slightly better support for font colors in bbcode converter - configurator now also uses pyqt5 - bugfix: bsa hashing function converted backslashes to slashes instead of the other way around. hash calculation is still often wrong on folder names... --- src/runner/proxypluginwrappers.cpp | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index bade563..ddaaf04 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -1,4 +1,4 @@ -#define HAVE_ROUND +//#define HAVE_ROUND #include "proxypluginwrappers.h" #include #include "error.h" @@ -27,63 +27,64 @@ bool IPluginToolWrapper::init(MOBase::IOrganizer *moInfo) QString IPluginToolWrapper::name() const { try { - return this->get_override("name")(); + return this->get_override("name")().as(); } PYCATCH; } QString IPluginToolWrapper::author() const { try { - return this->get_override("author")(); + return this->get_override("author")().as(); } PYCATCH; } QString IPluginToolWrapper::description() const { try { - return this->get_override("description")(); + return this->get_override("description")().as(); } PYCATCH; } MOBase::VersionInfo IPluginToolWrapper::version() const { try { - return this->get_override("version")(); + return this->get_override("version")().as(); } PYCATCH; } bool IPluginToolWrapper::isActive() const { try { - return this->get_override("isActive")(); + return this->get_override("isActive")().as(); } PYCATCH; } QList IPluginToolWrapper::settings() const { try { - return this->get_override("settings")(); + return this->get_override("settings")().as>(); } PYCATCH; } QString IPluginToolWrapper::displayName() const { try { - return this->get_override("displayName")(); + return this->get_override("displayName")().as(); } PYCATCH; } QString IPluginToolWrapper::tooltip() const { try { - return this->get_override("tooltip")(); + return this->get_override("tooltip")().as(); } PYCATCH; } QIcon IPluginToolWrapper::icon() const { try { - return this->get_override("icon")(); +qDebug("%p", this->get_override("icon").ptr()); + return this->get_override("icon")().as(); } PYCATCH; } @@ -118,21 +119,21 @@ bool IPluginInstallerCustomWrapper::init(MOBase::IOrganizer *moInfo) QString IPluginInstallerCustomWrapper::name() const { try { - return this->get_override("name")(); + return this->get_override("name")().as(); } PYCATCH; } QString IPluginInstallerCustomWrapper::author() const { try { - return this->get_override("author")(); + return this->get_override("author")().as(); } PYCATCH; } QString IPluginInstallerCustomWrapper::description() const { try { - return this->get_override("description")(); + return this->get_override("description")().as(); } PYCATCH; } @@ -153,7 +154,7 @@ bool IPluginInstallerCustomWrapper::isActive() const QList IPluginInstallerCustomWrapper::settings() const { try { - return this->get_override("settings")(); + return this->get_override("settings")().as>(); } PYCATCH; } @@ -189,7 +190,7 @@ bool IPluginInstallerCustomWrapper::isArchiveSupported(const QString &archiveNam std::set IPluginInstallerCustomWrapper::supportedExtensions() const { try { - return this->get_override("supportedExtensions")(); + return this->get_override("supportedExtensions")().as>(); } PYCATCH; } From 5da6a9d3bd2e831d08bd1f66cd6299ba75e9bb4b Mon Sep 17 00:00:00 2001 From: Tannin Date: Tue, 11 Nov 2014 23:48:22 +0100 Subject: [PATCH 06/10] - updated staging script to use qt5 and to fetch translations from transifex - removed call to function unavailable in Windows XP --- src/runner/pythonRunner.pro | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/runner/pythonRunner.pro b/src/runner/pythonRunner.pro index dbffac8..e6e7d71 100644 --- a/src/runner/pythonRunner.pro +++ b/src/runner/pythonRunner.pro @@ -42,11 +42,9 @@ CONFIG(debug, debug|release) { QMAKE_LFLAGS += /DEBUG } -INCLUDEPATH += "$${BOOSTPATH}" "$${PYTHONPATH}/include" "$${PYTHONPATH}/Lib/site-packages/PyQt4/include" +INCLUDEPATH += "$${BOOSTPATH}" "$${PYTHONPATH}/include" "$${PYTHONPATH}/Lib/site-packages/PyQt5/include" ../uibase LIBS += -L"$${PYTHONPATH}/libs" -L"$${BOOSTPATH}/stage/lib" LIBS += -lpython27 - -INCLUDEPATH += ../uibase LIBS += -luibase CONFIG(debug, debug|release) { From dec620b5b764685284b946803c1bdc05b77f02e0 Mon Sep 17 00:00:00 2001 From: Tannin Date: Fri, 21 Nov 2014 14:45:30 +0100 Subject: [PATCH 07/10] - started on a refactoring moving functionality out of the MainWindow class - started on support for game-plugins --- src/runner/pythonrunner.cpp | 1 + src/runner/uibasewrappers.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 719981c..2a3da87 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -727,6 +727,7 @@ BOOST_PYTHON_MODULE(mobase) .def("startApplication", bpy::pure_virtual(&IOrganizer::startApplication), bpy::return_value_policy()) .def("waitForApplication", bpy::pure_virtual(&IOrganizer::waitForApplication), bpy::return_value_policy()) .def("onAboutToRun", bpy::pure_virtual(&IOrganizer::onAboutToRun)) + .def("onFinishedRun", bpy::pure_virtual(&IOrganizer::onFinishedRun)) .def("onModInstalled", bpy::pure_virtual(&IOrganizer::onModInstalled)) .def("refreshModList", bpy::pure_virtual(&IOrganizer::refreshModList)) ; diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index 354346a..ec29b84 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -226,6 +226,7 @@ struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapperget_override("waitForApplication")(handle, exitCode); } virtual void refreshModList(bool saveChanges = true) { this->get_override("refreshModList")(saveChanges); } virtual bool onAboutToRun(const std::function &func) { return this->get_override("onAboutToRun")(func); } + virtual bool onFinishedRun(const std::function &func) { return this->get_override("onFinishedRun")(func); } virtual bool onModInstalled(const std::function &func) { return this->get_override("onModInstalled")(func); } }; From 868ab93a1fecd2a17d931728eb890de486a83418 Mon Sep 17 00:00:00 2001 From: Tannin Date: Fri, 28 Nov 2014 11:19:20 +0100 Subject: [PATCH 08/10] replaced all uses of NULL with nullptr fixed a few placed where NULL was used as a number or boolean --- src/proxy/proxypython.cpp | 26 +++++++++--------- src/runner/pythonrunner.cpp | 54 ++++++++++++++++++------------------- src/runner/uibasewrappers.h | 2 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/proxy/proxypython.cpp b/src/proxy/proxypython.cpp index 2592b7f..5f48c3c 100644 --- a/src/proxy/proxypython.cpp +++ b/src/proxy/proxypython.cpp @@ -37,7 +37,7 @@ const char *ProxyPython::s_DownloadPythonURL = "http://www.python.org/download/r HMODULE GetOwnModuleHandle() { - HMODULE hMod = NULL; + HMODULE hMod = nullptr; GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, reinterpret_cast(&GetOwnModuleHandle), &hMod); @@ -50,12 +50,12 @@ QString ExtractResource(WORD resourceID, const QString &szFilename) HMODULE mod = GetOwnModuleHandle(); HRSRC hResource = FindResourceW(mod, MAKEINTRESOURCE(resourceID), L"BINARY"); - if (hResource == NULL) { + if (hResource == nullptr) { throw MyException("embedded dll not available: " + windowsErrorString(::GetLastError())); } HGLOBAL hFileResource = LoadResource(mod, hResource); - if (hFileResource == NULL) { + if (hFileResource == nullptr) { throw MyException("failed to load embedded dll resource: " + windowsErrorString(::GetLastError())); } @@ -64,8 +64,8 @@ QString ExtractResource(WORD resourceID, const QString &szFilename) QString outFile = QDir::tempPath() + "/" + szFilename; - HANDLE hFile = CreateFileW(ToWString(outFile).c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - HANDLE hFileMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwSize, NULL); + HANDLE hFile = CreateFileW(ToWString(outFile).c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE hFileMap = CreateFileMapping(hFile, nullptr, PAGE_READWRITE, 0, dwSize, nullptr); LPVOID lpAddress = MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0); CopyMemory(lpAddress, lpFile, dwSize); @@ -81,7 +81,7 @@ QString ExtractResource(WORD resourceID, const QString &szFilename) ProxyPython::ProxyPython() - : m_MOInfo(NULL), m_Runner(NULL), m_LoadFailure(FAIL_NOTINIT) + : m_MOInfo(nullptr), m_Runner(nullptr), m_LoadFailure(FAIL_NOTINIT) { } @@ -119,9 +119,9 @@ bool ProxyPython::init(IOrganizer *moInfo) m_TempRunnerFile = ExtractResource(IDR_LOADER_DLL, "__pythonRunner.dll"); m_RunnerLib = ::LoadLibraryW(ToWString(m_TempRunnerFile).c_str()); - if (m_RunnerLib != NULL) { + if (m_RunnerLib != nullptr) { CreatePythonRunner_func CreatePythonRunner = (CreatePythonRunner_func)::GetProcAddress(m_RunnerLib, "CreatePythonRunner"); - if (CreatePythonRunner == NULL) { + if (CreatePythonRunner == nullptr) { throw MyException("embedded dll is invalid: " + windowsErrorString(::GetLastError())); } if (m_MOInfo->persistent(name(), "tryInit", false).toBool()) { @@ -146,7 +146,7 @@ bool ProxyPython::init(IOrganizer *moInfo) m_Runner = CreatePythonRunner(moInfo, pythonPath); m_MOInfo->setPersistent(name(), "tryInit", false); - if (m_Runner != NULL) { + if (m_Runner != nullptr) { m_LoadFailure = FAIL_NONE; } else { m_LoadFailure = FAIL_INITFAIL; @@ -210,11 +210,11 @@ QStringList ProxyPython::pluginList(const QString &pluginPath) const QObject *ProxyPython::instantiate(const QString &pluginName) { - if (m_Runner != NULL) { + if (m_Runner != nullptr) { QObject *result = m_Runner->instantiate(pluginName); return result; } else { - return NULL; + return nullptr; } } @@ -232,7 +232,7 @@ std::vector ProxyPython::activeProblems() const result.push_back(PROBLEM_INITFAIL); } else if (m_LoadFailure == FAIL_SEMICOLON) { result.push_back(PROBLEM_SEMICOLON); - } else if (m_Runner != NULL) { + } else if (m_Runner != nullptr) { if (!m_Runner->isPythonInstalled()) { // don't know how this could happen but wth result.push_back(PROBLEM_PYTHONMISSING); @@ -318,7 +318,7 @@ bool ProxyPython::hasGuidedFix(unsigned int key) const void ProxyPython::startGuidedFix(unsigned int key) const { if ((key == PROBLEM_PYTHONMISSING) || (key == PROBLEM_PYTHONWRONGVERSION)) { - ::ShellExecuteA(NULL, "open", s_DownloadPythonURL, NULL, NULL, SW_SHOWNORMAL); + ::ShellExecuteA(nullptr, "open", s_DownloadPythonURL, nullptr, nullptr, SW_SHOWNORMAL); } } diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 2a3da87..3d0ceaf 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -22,7 +22,7 @@ #endif -MOBase::IOrganizer *s_Organizer = NULL; +MOBase::IOrganizer *s_Organizer = nullptr; @@ -55,7 +55,7 @@ IPythonRunner *CreatePythonRunner(MOBase::IOrganizer *moInfo, const QString &pyt return result; } else { delete result; - return NULL; + return nullptr; } } @@ -103,13 +103,13 @@ struct QString_from_python_str } static void *convertible(PyObject *objPtr) { - return PyString_Check(objPtr) ? objPtr : NULL; + return PyString_Check(objPtr) ? objPtr : nullptr; } static void construct(PyObject *objPtr, bpy::converter::rvalue_from_python_stage1_data *data) { // Extract the character data from the python string const char* value = PyString_AsString(objPtr); - assert(value != NULL); + assert(value != nullptr); // allocate storage void *storage = ((bpy::converter::rvalue_from_python_storage*)data)->storage.bytes; @@ -146,7 +146,7 @@ struct GuessedValue_converters if PyList_Check(objPtr) { return objPtr; } else { - return NULL; + return nullptr; } } @@ -217,7 +217,7 @@ struct QVariant_from_python_obj static void *convertible(PyObject *objPtr) { if (!PyString_Check(objPtr) && !PyInt_Check(objPtr) && !PyBool_Check(objPtr) && !PyList_Check(objPtr)) { - return NULL; + return nullptr; } return objPtr; } @@ -310,7 +310,7 @@ struct QList_from_python_obj static void* convertible(PyObject *objPtr) { if (PyList_Check(objPtr)) return objPtr; - return NULL; + return nullptr; } static void construct(PyObject *objPtr, bpy::converter::rvalue_from_python_stage1_data *data) { @@ -339,7 +339,7 @@ struct stdset_from_python_list static void* convertible(PyObject *objPtr) { if (PyList_Check(objPtr)) return objPtr; - return NULL; + return nullptr; } static void construct(PyObject *objPtr, bpy::converter::rvalue_from_python_stage1_data *data) { @@ -359,8 +359,8 @@ struct stdset_from_python_list static const sipAPIDef *sipAPI() { - static const sipAPIDef *sipApi = NULL; - if (sipApi == NULL) { + static const sipAPIDef *sipApi = nullptr; + if (sipApi == nullptr) { sipApi = (const sipAPIDef *)PyCapsule_Import("sip._C_API", 0); } @@ -393,19 +393,19 @@ template <> struct MetaData { static const char *className() { return template PyObject *toPyQt(T *objPtr) { - if (objPtr == NULL) { + if (objPtr == nullptr) { qDebug("no input object"); return bpy::incref(Py_None); } const sipTypeDef *type = sipAPI()->api_find_type(MetaData::className()); - if (type == NULL) { + if (type == nullptr) { qDebug("failed to determine type: %s", MetaData::className()); return bpy::incref(Py_None); } PyObject *sipObj = sipAPI()->api_convert_from_type(objPtr, type, 0); - if (sipObj == NULL) { + if (sipObj == nullptr) { qDebug("failed to convert"); return bpy::incref(Py_None); } @@ -420,12 +420,12 @@ struct QClass_converters { static PyObject *convert(const T &object) { const sipTypeDef *type = sipAPI()->api_find_type(MetaData::className()); - if (type == NULL) { + if (type == nullptr) { return bpy::incref(Py_None); } PyObject *sipObj = sipAPI()->api_convert_from_type((void*)(&object), type, 0); - if (sipObj == NULL) { + if (sipObj == nullptr) { return bpy::incref(Py_None); } @@ -433,17 +433,17 @@ struct QClass_converters } static PyObject *convert(T *object) { - if (object == NULL) { + if (object == nullptr) { return bpy::incref(Py_None); } const sipTypeDef *type = sipAPI()->api_find_type(MetaData::className()); - if (type == NULL) { + if (type == nullptr) { return bpy::incref(Py_None); } PyObject *sipObj = sipAPI()->api_convert_from_type(object, type, 0); - if (sipObj == NULL) { + if (sipObj == nullptr) { return bpy::incref(Py_None); } @@ -484,12 +484,12 @@ struct QInterface_converters { static PyObject *convert(const T &object) { const sipTypeDef *type = sipAPI()->api_find_type(MetaData::className()); - if (type == NULL) { + if (type == nullptr) { return bpy::incref(Py_None); } PyObject *sipObj = sipAPI()->api_convert_from_type((void*)(&object), type, 0); - if (sipObj == NULL) { + if (sipObj == nullptr) { return bpy::incref(Py_None); } @@ -497,17 +497,17 @@ struct QInterface_converters } static PyObject *convert(T *object) { - if (object == NULL) { + if (object == nullptr) { return bpy::incref(Py_None); } const sipTypeDef *type = sipAPI()->api_find_type(MetaData::className()); - if (type == NULL) { + if (type == nullptr) { return bpy::incref(Py_None); } PyObject *sipObj = sipAPI()->api_convert_from_type(object, type, 0); - if (sipObj == NULL) { + if (sipObj == nullptr) { return bpy::incref(Py_None); } @@ -579,7 +579,7 @@ struct Functor0_converter { if (!PyCallable_Check(object) || (getArgCount(object) != 0)) { - return NULL; + return nullptr; } return object; } @@ -620,7 +620,7 @@ struct Functor2_converter { if (!PyCallable_Check(object) || (getArgCount(object) != 2)) { - return NULL; + return nullptr; } return object; } @@ -937,7 +937,7 @@ QObject *PythonRunner::instantiate(const QString &pluginName) std::string temp = ToString(pluginName); if (handled_exec_file(temp.c_str(), moduleNamespace)) { reportPythonError(); - return NULL; + return nullptr; } m_PythonObjects[pluginName] = moduleNamespace["createPlugin"](); @@ -948,7 +948,7 @@ QObject *PythonRunner::instantiate(const QString &pluginName) qWarning("failed to run python script \"%s\"", qPrintable(pluginName)); reportPythonError(); } - return NULL; + return nullptr; } bool PythonRunner::isPythonInstalled() const diff --git a/src/runner/uibasewrappers.h b/src/runner/uibasewrappers.h index ec29b84..faf4456 100644 --- a/src/runner/uibasewrappers.h +++ b/src/runner/uibasewrappers.h @@ -223,7 +223,7 @@ struct IOrganizerWrapper: MOBase::IOrganizer, boost::python::wrapperget_override("getFileOrigins")(fileName); } virtual QList findFileInfos(const QString &path, const std::function &filter) const { return this->get_override("findFileInfos")(path, filter); } virtual HANDLE startApplication(const QString &executable, const QStringList &args = QStringList(), const QString &cwd = "", const QString &profile = "") { return this->get_override("startApplication")(executable, args, cwd, profile); } - virtual bool waitForApplication(HANDLE handle, LPDWORD exitCode = NULL) const { return this->get_override("waitForApplication")(handle, exitCode); } + virtual bool waitForApplication(HANDLE handle, LPDWORD exitCode = nullptr) const { return this->get_override("waitForApplication")(handle, exitCode); } virtual void refreshModList(bool saveChanges = true) { this->get_override("refreshModList")(saveChanges); } virtual bool onAboutToRun(const std::function &func) { return this->get_override("onAboutToRun")(func); } virtual bool onFinishedRun(const std::function &func) { return this->get_override("onFinishedRun")(func); } From bbea63e7afda404d1bdadf66fcc140bb230eb994 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 4 Jan 2015 10:13:12 +0100 Subject: [PATCH 09/10] - fixes after merge --- src/runner/pythonRunner.pro | 3 +-- src/runner/pythonrunner.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/runner/pythonRunner.pro b/src/runner/pythonRunner.pro index e6e7d71..4da9d64 100644 --- a/src/runner/pythonRunner.pro +++ b/src/runner/pythonRunner.pro @@ -13,14 +13,13 @@ CONFIG += warn_on DEFINES += PYTHONRUNNER_LIBRARY # suppress a few warnings caused by boost vs vc++ paranoia -DEFINES += _SCL_SECURE_NO_WARNINGS -DHAVE_ROUND +DEFINES += _SCL_SECURE_NO_WARNINGS !include(../LocalPaths.pri) { message("paths to required libraries need to be set up in LocalPaths.pri") } - SOURCES += pythonrunner.cpp \ gilock.cpp \ error.cpp \ diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 2a3da87..0c328f4 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -841,7 +841,7 @@ PythonRunner::PythonRunner(const MOBase::IOrganizer *moInfo) m_PythonHome = new char[MAX_PATH + 1]; } -static char* argv0 = "ModOrganizer.exe"; +static const char *argv0 = "ModOrganizer.exe"; bool PythonRunner::initPython(const QString &pythonPath) @@ -855,7 +855,10 @@ bool PythonRunner::initPython(const QString &pythonPath) Py_SetPythonHome(m_PythonHome); } - Py_SetProgramName(argv0); + char argBuffer[MAX_PATH]; + strcpy(argBuffer, argv0); + + Py_SetProgramName(argBuffer); PyImport_AppendInittab("mobase", &initmobase); Py_OptimizeFlag = 2; Py_NoSiteFlag = 1; @@ -865,7 +868,7 @@ bool PythonRunner::initPython(const QString &pythonPath) return false; } - PySys_SetArgv(0, &argv0); + PySys_SetArgv(0, (char**)&argBuffer); bpy::object mainModule = bpy::import("__main__"); bpy::object mainNamespace = mainModule.attr("__dict__"); From c7203bf9de6840b078f389d2fc0c943b3b7117cd Mon Sep 17 00:00:00 2001 From: Tannin Date: Tue, 6 Jan 2015 19:31:53 +0100 Subject: [PATCH 10/10] - bugfixes - moved more functionality to game-plugins - further decoupled management functionality from the UI - created another "tutorial" which is only a single page with relevant parts of the ui highlighted with info as tooltips --- src/proxy/proxypython.cpp | 4 ++-- src/runner/proxypluginwrappers.cpp | 2 -- src/runner/pythonRunner.pro | 2 +- src/runner/pythonrunner.cpp | 2 -- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/proxy/proxypython.cpp b/src/proxy/proxypython.cpp index 5f48c3c..c5b7807 100644 --- a/src/proxy/proxypython.cpp +++ b/src/proxy/proxypython.cpp @@ -64,7 +64,7 @@ QString ExtractResource(WORD resourceID, const QString &szFilename) QString outFile = QDir::tempPath() + "/" + szFilename; - HANDLE hFile = CreateFileW(ToWString(outFile).c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + HANDLE hFile = CreateFileW(outFile.toStdWString().c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); HANDLE hFileMap = CreateFileMapping(hFile, nullptr, PAGE_READWRITE, 0, dwSize, nullptr); LPVOID lpAddress = MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0); @@ -154,7 +154,7 @@ bool ProxyPython::init(IOrganizer *moInfo) return true; } else { DWORD error = ::GetLastError(); - qCritical("Failed to load python runner: %s", qPrintable(windowsErrorString(error))); + qCritical("Failed to load python runner (%s): %s", qPrintable(m_TempRunnerFile), qPrintable(windowsErrorString(error))); if (error == ERROR_MOD_NOT_FOUND) { m_LoadFailure = FAIL_MISSINGDEPENDENCIES; } diff --git a/src/runner/proxypluginwrappers.cpp b/src/runner/proxypluginwrappers.cpp index ddaaf04..b5d3b6a 100644 --- a/src/runner/proxypluginwrappers.cpp +++ b/src/runner/proxypluginwrappers.cpp @@ -1,4 +1,3 @@ -//#define HAVE_ROUND #include "proxypluginwrappers.h" #include #include "error.h" @@ -83,7 +82,6 @@ QString IPluginToolWrapper::tooltip() const QIcon IPluginToolWrapper::icon() const { try { -qDebug("%p", this->get_override("icon").ptr()); return this->get_override("icon")().as(); } PYCATCH; } diff --git a/src/runner/pythonRunner.pro b/src/runner/pythonRunner.pro index 4da9d64..a0aceed 100644 --- a/src/runner/pythonRunner.pro +++ b/src/runner/pythonRunner.pro @@ -13,7 +13,7 @@ CONFIG += warn_on DEFINES += PYTHONRUNNER_LIBRARY # suppress a few warnings caused by boost vs vc++ paranoia -DEFINES += _SCL_SECURE_NO_WARNINGS +DEFINES += _SCL_SECURE_NO_WARNINGS HAVE_ROUND !include(../LocalPaths.pri) { diff --git a/src/runner/pythonrunner.cpp b/src/runner/pythonrunner.cpp index 31f42df..0749e44 100644 --- a/src/runner/pythonrunner.cpp +++ b/src/runner/pythonrunner.cpp @@ -1,5 +1,3 @@ -#define HAVE_ROUND - #include "pythonrunner.h" #pragma warning( disable : 4100 )