Skip to content
Permalink
Browse files

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 d315a12362714703b273f062e8f9a9cb342c4289
Showing with 19 additions and 14 deletions.
  1. +19 −14 src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
@@ -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;
}
}
}
}

0 comments on commit d315a12

Please sign in to comment.
You can’t perform that action at this time.