Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix segfault when editor widget is invalid on form init
"editor" can be null in that case
  • Loading branch information
elpaso authored and m-kuhn committed Nov 19, 2015
1 parent c40a764 commit d315a12
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
Expand Up @@ -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() )
{
// if it's a perfect match: return it directly
return it.value().second;
}
else if ( editor->inherits( it.key() ) )
int weight = 0;

it = mFactoriesByType.constBegin();
for ( ; it != mFactoriesByType.constEnd(); ++it )
{
// 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() )
{
// if it's a perfect match: return it directly
return it.value().second;
}
else if ( editor->inherits( it.key() ) )
{
weight = it.value().first;
widgetid = it.value().second;
// 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;
}
}
}
}
Expand Down

0 comments on commit d315a12

Please sign in to comment.