Fix for failing testScriptedEffectsLoader
By changing the loading of scripted effect config to interact with kwinApp we broke the tests which do not use a kwinApp. This change turns the access to the KSharedConfigPtr go through the property system, so that the tests can also install a dummy KSharedConfigPtr. With that scripted effects loader test passes and no longer crashes and the integration/effects tests also still pass.
This commit is contained in:
parent
1c819c5e86
commit
6184278bec
4 changed files with 15 additions and 2 deletions
|
@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
Q_DECLARE_METATYPE(KWin::LoadEffectFlag)
|
||||
Q_DECLARE_METATYPE(KWin::LoadEffectFlags)
|
||||
Q_DECLARE_METATYPE(KWin::Effect*)
|
||||
Q_DECLARE_METATYPE(KSharedConfigPtr)
|
||||
|
||||
Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core")
|
||||
|
||||
|
@ -64,6 +65,7 @@ class TestScriptedEffectLoader : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testHasEffect_data();
|
||||
void testHasEffect();
|
||||
void testKnownEffects();
|
||||
|
@ -75,6 +77,12 @@ private Q_SLOTS:
|
|||
void testCancelLoadAllEffects();
|
||||
};
|
||||
|
||||
void TestScriptedEffectLoader::initTestCase()
|
||||
{
|
||||
auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
QCoreApplication::instance()->setProperty("config", QVariant::fromValue(config));
|
||||
}
|
||||
|
||||
void TestScriptedEffectLoader::testHasEffect_data()
|
||||
{
|
||||
QTest::addColumn<QString>("name");
|
||||
|
|
3
main.cpp
3
main.cpp
|
@ -65,6 +65,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define XCB_GE_GENERIC 35
|
||||
#endif
|
||||
|
||||
Q_DECLARE_METATYPE(KSharedConfigPtr)
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -107,6 +109,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv
|
|||
qRegisterMetaType<Options::WindowOperation>("Options::WindowOperation");
|
||||
qRegisterMetaType<KWin::EffectWindow*>();
|
||||
qRegisterMetaType<KWayland::Server::SurfaceInterface *>("KWayland::Server::SurfaceInterface *");
|
||||
qRegisterMetaType<KSharedConfigPtr>();
|
||||
}
|
||||
|
||||
void Application::setConfigLock(bool lock)
|
||||
|
|
1
main.h
1
main.h
|
@ -54,6 +54,7 @@ class KWIN_EXPORT Application : public QApplication
|
|||
Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT)
|
||||
Q_PROPERTY(void *x11Connection READ x11Connection NOTIFY x11ConnectionChanged)
|
||||
Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT)
|
||||
Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig)
|
||||
public:
|
||||
/**
|
||||
* @brief This enum provides the various operation modes of KWin depending on the available
|
||||
|
|
|
@ -23,7 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "scriptingutils.h"
|
||||
#include "workspace_wrapper.h"
|
||||
#include "../screenedge.h"
|
||||
#include "../main.h"
|
||||
#include "scripting_logging.h"
|
||||
// KDE
|
||||
#include <KConfigGroup>
|
||||
|
@ -37,6 +36,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
typedef KWin::EffectWindow* KEffectWindowRef;
|
||||
|
||||
Q_DECLARE_METATYPE(KSharedConfigPtr)
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -483,7 +484,7 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
|
|||
// does the effect contain an KConfigXT file?
|
||||
const QString kconfigXTFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(KWIN_NAME "/effects/") + m_effectName + QLatin1String("/contents/config/main.xml"));
|
||||
if (!kconfigXTFile.isNull()) {
|
||||
KConfigGroup cg = kwinApp()->config()->group(QStringLiteral("Effect-%1").arg(m_effectName));
|
||||
KConfigGroup cg = QCoreApplication::instance()->property("config").value<KSharedConfigPtr>()->group(QStringLiteral("Effect-%1").arg(m_effectName));
|
||||
QFile xmlFile(kconfigXTFile);
|
||||
m_config = new KConfigLoader(cg, &xmlFile, this);
|
||||
m_config->load();
|
||||
|
|
Loading…
Reference in a new issue