mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Fix segfault when editor widget is invalid on form init
"editor" can be null in that case
This commit is contained in:
parent
c40a764f5c
commit
d315a12362
@ -351,23 +351,28 @@ QString QgsEditorWidgetRegistry::findSuitableWrapper( QWidget* editor, const QSt
|
||||
QMap<const char*, QPair<int, QString> >::ConstIterator it;
|
||||
|
||||
QString widgetid;
|
||||
int weight = 0;
|
||||
|
||||
it = mFactoriesByType.constBegin();
|
||||
for ( ; it != mFactoriesByType.constEnd(); ++it )
|
||||
|
||||
// Editor can be null
|
||||
if ( editor )
|
||||
{
|
||||
if ( editor->staticMetaObject.className() == it.key() )
|
||||
int weight = 0;
|
||||
|
||||
it = mFactoriesByType.constBegin();
|
||||
for ( ; it != mFactoriesByType.constEnd(); ++it )
|
||||
{
|
||||
// if it's a perfect match: return it directly
|
||||
return it.value().second;
|
||||
}
|
||||
else if ( editor->inherits( it.key() ) )
|
||||
{
|
||||
// if it's a subclass, continue evaluating, maybe we find a more-specific or one with more weight
|
||||
if ( it.value().first > weight )
|
||||
if ( editor->staticMetaObject.className() == it.key() )
|
||||
{
|
||||
weight = it.value().first;
|
||||
widgetid = it.value().second;
|
||||
// if it's a perfect match: return it directly
|
||||
return it.value().second;
|
||||
}
|
||||
else if ( editor->inherits( it.key() ) )
|
||||
{
|
||||
// if it's a subclass, continue evaluating, maybe we find a more-specific or one with more weight
|
||||
if ( it.value().first > weight )
|
||||
{
|
||||
weight = it.value().first;
|
||||
widgetid = it.value().second;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user