Skip to content
Permalink
Browse files

Don't use global static QIcon's, they crash Qt5 on exit

  • Loading branch information
m-kuhn committed Apr 12, 2016
1 parent 0adae36 commit ca0bf6feb103bd262ebb8b1f005aa9c3d18de41a
@@ -202,8 +202,6 @@ const QIcon &QgsZipItem::iconZip()
return icon;
}

QMap<QString, QIcon> QgsDataItem::mIconMap = QMap<QString, QIcon>();

QgsAnimatedIcon * QgsDataItem::mPopulatingIcon = nullptr;

QgsDataItem::QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, const QString& name, const QString& path )
@@ -247,7 +247,7 @@ class CORE_EXPORT QgsDataItem : public QObject
QString mToolTip;
QString mIconName;
QIcon mIcon;
static QMap<QString, QIcon> mIconMap;
QMap<QString, QIcon> mIconMap;

public slots:
/** Safely delete the item:
@@ -27,9 +27,6 @@
#include <QSettings>
#include <QScrollArea>

QIcon QgsCollapsibleGroupBoxBasic::mCollapseIcon;
QIcon QgsCollapsibleGroupBoxBasic::mExpandIcon;

QgsCollapsibleGroupBoxBasic::QgsCollapsibleGroupBoxBasic( QWidget *parent )
: QGroupBox( parent )
{
@@ -65,11 +62,8 @@ void QgsCollapsibleGroupBoxBasic::init()
mTitleClicked = false;

// init icons
if ( mCollapseIcon.isNull() )
{
mCollapseIcon = QgsApplication::getThemeIcon( "/mIconCollapse.png" );
mExpandIcon = QgsApplication::getThemeIcon( "/mIconExpand.png" );
}
mCollapseIcon = QgsApplication::getThemeIcon( "/mIconCollapse.png" );
mExpandIcon = QgsApplication::getThemeIcon( "/mIconExpand.png" );

// collapse button
mCollapseButton = new QgsGroupBoxCollapseButton( this );
@@ -159,8 +159,8 @@ class GUI_EXPORT QgsCollapsibleGroupBoxBasic : public QGroupBox
bool mShiftDown;
bool mTitleClicked;

static QIcon mCollapseIcon;
static QIcon mExpandIcon;
QIcon mCollapseIcon;
QIcon mExpandIcon;
};

/** \ingroup gui
@@ -28,14 +28,6 @@
#include <QPointer>
#include <QGroupBox>


QIcon QgsDataDefinedButton::mIconDataDefine;
QIcon QgsDataDefinedButton::mIconDataDefineOn;
QIcon QgsDataDefinedButton::mIconDataDefineError;
QIcon QgsDataDefinedButton::mIconDataDefineExpression;
QIcon QgsDataDefinedButton::mIconDataDefineExpressionOn;
QIcon QgsDataDefinedButton::mIconDataDefineExpressionError;

QgsDataDefinedButton::QgsDataDefinedButton( QWidget* parent,
const QgsVectorLayer* vl,
const QgsDataDefined* datadefined,
@@ -370,12 +370,12 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton

QScopedPointer<QgsDataDefinedAssistant> mAssistant;

static QIcon mIconDataDefine;
static QIcon mIconDataDefineOn;
static QIcon mIconDataDefineError;
static QIcon mIconDataDefineExpression;
static QIcon mIconDataDefineExpressionOn;
static QIcon mIconDataDefineExpressionError;
QIcon mIconDataDefine;
QIcon mIconDataDefineOn;
QIcon mIconDataDefineError;
QIcon mIconDataDefineExpression;
QIcon mIconDataDefineExpressionOn;
QIcon mIconDataDefineExpressionError;

ExpressionContextCallback mExpressionContextCallback;
const void* mExpressionContextCallbackContext;
@@ -240,25 +240,6 @@ int QgsFieldModel::columnCount( const QModelIndex &parent ) const

QVariant QgsFieldModel::data( const QModelIndex &index, int role ) const
{
static QIcon intIcon;
if ( intIcon.isNull() )
intIcon = QgsApplication::getThemeIcon( "/mIconFieldInteger.svg" );
static QIcon floatIcon;
if ( floatIcon.isNull() )
floatIcon = QgsApplication::getThemeIcon( "/mIconFieldFloat.svg" );
static QIcon stringIcon;
if ( stringIcon.isNull() )
stringIcon = QgsApplication::getThemeIcon( "/mIconFieldText.svg" );
static QIcon dateIcon;
if ( dateIcon.isNull() )
dateIcon = QgsApplication::getThemeIcon( "/mIconFieldDate.svg" );
static QIcon dateTimeIcon;
if ( dateTimeIcon.isNull() )
dateTimeIcon = QgsApplication::getThemeIcon( "/mIconFieldDateTime.svg" );
static QIcon timeIcon;
if ( timeIcon.isNull() )
timeIcon = QgsApplication::getThemeIcon( "/mIconFieldTime.svg" );

if ( !index.isValid() )
return QVariant();

@@ -247,8 +247,6 @@ void QgsVariableEditorWidget::selectionChanged()
// VariableEditorTree
//

QIcon QgsVariableEditorTree::mExpandIcon;

QgsVariableEditorTree::QgsVariableEditorTree( QWidget *parent )
: QTreeWidget( parent )
, mEditorDelegate( nullptr )
@@ -187,7 +187,7 @@ class QgsVariableEditorTree : public QTreeWidget

QModelIndex moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) override;

static QIcon mExpandIcon;
QIcon mExpandIcon;

private:

4 comments on commit ca0bf6f

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Apr 12, 2016

@m-kuhn is there an alternative approach we could use here? (Eg Q_GLOBAL_STATIC?) The non static icons make the field model very sluggish.

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Apr 12, 2016

Actually maybe thats not an issue anymore... Doesn't look like they were even used.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Apr 12, 2016

They are still in qgsfield.cpp, it looks like these ones here were not really in use. Since the ones in qgsfield.cpp don't seem to be an issue for the tests right now, I left them in place.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Apr 12, 2016

But if it turns out that this commit introduced issues, I would opt to add a cache to QgsApplication::getThemeIcon and clear the cache before exiting.

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