[mythtv-commits] mythtv commit: r14813 by danielk
mythtv at cvs.mythtv.org
mythtv at cvs.mythtv.org
Wed Nov 7 17:52:58 UTC 2007
Author: danielk
Date: 2007-11-07 17:52:57 +0000 (Wed, 07 Nov 2007)
New Revision: 14813
Changeset: http://cvs.mythtv.org/trac/changeset/14813
Modified:
trunk/mythtv/libs/libmyth/mythcontext.h
trunk/mythtv/libs/libmyth/settings.cpp
trunk/mythtv/libs/libmyth/settings.h
Log:
Fixes #4128. Refs #4096. This fixes segfault on use of invalid widget pointer in "Capture cards", "Video sources" and "Input connections" screen.
*** This changeset requires a "make distclean" due to ABI changes in settings.h ***
These segfaults were a regression caused by [14791] which fixed #4096.
The problem in #4096 was that the "destroyed(void)" signal of the QWidget returned by ListBoxSetting::configWidget() was being used to set a different QWidget pointer to NULL. Unfortunately, the QWidget we were getting the "destroyed()" signal for was not the last QWidget ListBoxSetting::configWidget() had returned. This caused us to enter an inconsistent state.
This problem is also present in other Configurables which use a pointer to a QWidget to update the UI after the configWidget() call.
The solution is to invalidate the QWidget pointers before configWidget() is called again on a Configurable. To do this I added a virtual widgetInvalid(QObject*) method to Configurable. The one in configurable one does nothing, because most Configurables do not use a QWidget pointers. But those that do can use this to clear the pointers. This is called by all classes that call configWidget() before the widget is either deleted or configWidget() is called again on the same Configurable, basically it is called when the widget is removed from it's layout. This ensures the Configrables that rely on a QWidget pointer can be sure it is set NULLed before the widget is deleted but before configWidget() is called again.
But I also wanted to make sure that if widgetInvalid(QObject*) is called after configWidget() is called again on a Configurable, this will not cause any problems. So widgetInvalid's param is the pointer it returned from configWidget(). If this doesn't match the last pointer returned from configWidget() the Configrable must ignore the widgedInvalid() call.
Since we give the widget pointer to the Configurable in widgetInvalid() we can also call it on the destroyed(QObject*) signal. This shouldn't be needed, but if any class forgets a widgetInvalid() call on a widget they instanciated, this will prevent the Configurable from having a pointer to a deleted QWidget. Unlike the primary fix of calling widgetInvalid() at the appropriate times, this doesn't prevent a Configurable from updating the wrong QWidget if a Configurable is being updated from outside the Qt event thread, but it does prevent this error from causing a segfault.
More information about the mythtv-commits
mailing list