diff --git a/libs/ui/KisActionPlugin.cpp b/libs/ui/KisActionPlugin.cpp index 3968b9ffe1..dba3a391c0 100644 --- a/libs/ui/KisActionPlugin.cpp +++ b/libs/ui/KisActionPlugin.cpp @@ -1,68 +1,68 @@ /* * Copyright (c) 2013 Sven Langkamp * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "KisActionPlugin.h" #include "KisViewManager.h" #include "kis_action_manager.h" #include "operations/kis_operation.h" KisActionPlugin::KisActionPlugin(QObject* parent) : QObject(parent) { m_viewManager = qobject_cast(parent); - Q_ASSERT(m_viewManager); + KIS_ASSERT_RECOVER_NOOP(m_viewManager); } KisActionPlugin::~KisActionPlugin() { } void KisActionPlugin::addAction(const QString& name, KisAction* action) { if (m_viewManager) { m_viewManager->actionManager()->addAction(name, action); } } KisAction* KisActionPlugin::createAction(const QString& name) { if (m_viewManager) { return m_viewManager->actionManager()->createAction(name); } return 0; } void KisActionPlugin::addUIFactory(KisOperationUIFactory* factory) { if (m_viewManager) { m_viewManager->actionManager()->registerOperationUIFactory(factory); } } void KisActionPlugin::addOperation(KisOperation* operation) { if (m_viewManager) { m_viewManager->actionManager()->registerOperation(operation); } } QPointer KisActionPlugin::viewManager() const { return m_viewManager; } diff --git a/plugins/extensions/pykrita/plugin/plugin.cpp b/plugins/extensions/pykrita/plugin/plugin.cpp index cd89832fa8..61cd856b12 100644 --- a/plugins/extensions/pykrita/plugin/plugin.cpp +++ b/plugins/extensions/pykrita/plugin/plugin.cpp @@ -1,95 +1,95 @@ /* * Copyright (c) 2014 Boudewijn Rempt (boud@valdyas.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "plugin.h" #include #include #include #include #include "pyqtpluginsettings.h" #include K_PLUGIN_FACTORY_WITH_JSON(KritaPyQtPluginFactory, "kritapykrita.json", registerPlugin();) KritaPyQtPlugin::KritaPyQtPlugin(QObject *parent, const QVariantList &) - : KisActionPlugin(parent) + : QObject(parent) , m_autoReload(false) { dbgScript << "Loading Python plugin"; PyKrita::InitResult initResult = PyKrita::initialize(); switch (initResult) { case PyKrita::INIT_OK: break; case PyKrita::INIT_CANNOT_LOAD_PYTHON_LIBRARY: qWarning() << i18n("Cannot load Python library"); return; case PyKrita::INIT_CANNOT_SET_PYTHON_PATHS: qWarning() << i18n("Cannot set Python paths"); return; case PyKrita::INIT_CANNOT_LOAD_PYKRITA_MODULE: qWarning() << i18n("Cannot load built-in pykrita module"); return; default: qWarning() << i18n("Unexpected error initializing python plugin."); return; } pluginManager = PyKrita::pluginManager(); KisPreferenceSetRegistry *preferenceSetRegistry = KisPreferenceSetRegistry::instance(); PyQtPluginSettingsFactory* settingsFactory = new PyQtPluginSettingsFactory(pluginManager); //load and save preferences //if something in kritarc is missing, then the default from this load function will be used and saved back to kconfig. //this way, cfg.readEntry() in any part won't be able to set its own default KisPreferenceSet* settings = settingsFactory->createPreferenceSet(); KIS_SAFE_ASSERT_RECOVER_RETURN(settings); settings->loadPreferences(); settings->savePreferences(); delete settings; preferenceSetRegistry->add("PyQtPluginSettingsFactory", settingsFactory); // Try to import the `pykrita` module PyKrita::Python py = PyKrita::Python(); PyObject* pykritaPackage = py.moduleImport("pykrita"); pykritaPackage = py.moduleImport("krita"); if (pykritaPackage) { dbgScript << "Loaded pykrita, now load plugins"; pluginManager->scanPlugins(); pluginManager->tryLoadEnabledPlugins(); //py.functionCall("_pykritaLoaded", PyKrita::Python::PYKRITA_ENGINE); } else { dbgScript << "Cannot load pykrita module"; } Q_FOREACH (Extension *extension, Krita::instance()->extensions()) { extension->setup(); } } KritaPyQtPlugin::~KritaPyQtPlugin() { PyKrita::finalize(); } #include "plugin.moc" diff --git a/plugins/extensions/pykrita/plugin/plugin.h b/plugins/extensions/pykrita/plugin/plugin.h index f7fbe40cdd..2682286a40 100644 --- a/plugins/extensions/pykrita/plugin/plugin.h +++ b/plugins/extensions/pykrita/plugin/plugin.h @@ -1,41 +1,41 @@ /* * This file is part of PyKrita, Krita' Python scripting plugin. * * Copyright (C) 2013 Alex Turbov * Copyright (C) 2014-2016 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) version 3. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef _PYQT_PLUGIN_H_ #define _PYQT_PLUGIN_H_ #include #include #include "PythonPluginManager.h" -class KritaPyQtPlugin : public KisActionPlugin +class KritaPyQtPlugin : public QObject { Q_OBJECT public: KritaPyQtPlugin(QObject *parent, const QVariantList &); virtual ~KritaPyQtPlugin(); private: PythonPluginManager *pluginManager; bool m_autoReload; }; #endif