Skip to content
Permalink
Browse files

Make sure attribute table doesn't use deleted field formatters

  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent c6dc31a commit afacbb1320b749693f43a4b181e54c9f70053424
@@ -28,6 +28,7 @@ class QgsFieldFormatterRegistry : QObject
void removeFieldFormatter( QgsFieldFormatter* formatter );
void removeFieldFormatter( const QString& id );
QgsFieldFormatter* fieldFormatter( const QString& id ) const;
QgsFieldFormatter* fallbackFieldFormatter() const;
signals:
void fieldFormatterAdded( QgsFieldFormatter* formatter );
void fieldFormatterRemoved( QgsFieldFormatter* formatter );
@@ -68,3 +68,8 @@ QgsFieldFormatter* QgsFieldFormatterRegistry::fieldFormatter( const QString& id
{
return mFieldFormatters.value( id, mFallbackFieldFormatter );
}

QgsFieldFormatter* QgsFieldFormatterRegistry::fallbackFieldFormatter() const
{
return mFallbackFieldFormatter;
}
@@ -69,6 +69,12 @@ class CORE_EXPORT QgsFieldFormatterRegistry : public QObject
*/
QgsFieldFormatter* fieldFormatter( const QString& id ) const;

/**
* Returns a basic fallback field formatter which can be used
* to represent any field in an unspectacular manner.
*/
QgsFieldFormatter* fallbackFieldFormatter() const;

signals:

/**
@@ -269,10 +269,10 @@ void QgsAttributeTableModel::layerDeleted()

void QgsAttributeTableModel::fieldFormatterRemoved( QgsFieldFormatter* fieldFormatter )
{
for ( QVector<QgsFieldFormatter*>::Iterator it = mFieldFormatters.begin(); it != mFieldFormatters.end(); ++it )
for ( int i = 0; i < mFieldFormatters.size(); ++i )
{
if ( it.value() == fieldFormatter )
it.setValue( QgsApplication::fieldFormatterRegistry()->defaultFormatter() );
if ( mFieldFormatters.at( i ) == fieldFormatter )
mFieldFormatters[i] = QgsApplication::fieldFormatterRegistry()->fallbackFieldFormatter();
}
}

0 comments on commit afacbb1

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