[PyQt] Problems with KSharedConfig

Benjamin Kleiner bizzl.greekdog at web.de
Wed Jan 21 16:45:38 GMT 2009


I am trying to convert the toggle-compositing plasmoid from C++ to Python and ended up having a problem with KSharedConfig.
The original uses the following code to modify the config of kwin:

	void ToggleCompositing::writeState(bool state) {
		KSharedConfigPtr mKWinConfig=KSharedConfig::openConfig("kwinrc");
		KConfigGroup config(mKWinConfig, "Compositing");
		m_state = config.readEntry("Enabled", false);
		if (m_state != state) {
			config.writeEntry("Enabled", state);
			m_state = state;
			mKWinConfig->sync();
		}
	}

I tried to follow a narrowly and got this:

	def writeState(self, newValue):
		config = KSharedConfig.openConfig("kwinrc")
		configGroup = config.group("Compositing")
		if configGroup.readEntry("Enabled", QVariant(False) ).toBool() != newValue:
			configGroup.writeEntry("Enabled", newValue)
			configGroup.sync()
		return configGroup.readEntry("Enabled", QVariant(False) ).toBool()

It always crashes on the third line. No backtrace, sorry. Python doesn't give me anything, and KCrash says it can't load the necessary symbols :/
I've already tried it with the normal KConfig class, with the result that it only crashes at every second try (nothing happens after the first, though)...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090121/5c2b7e2e/attachment.html


More information about the PyQt mailing list