Skip to content

Commit

Permalink
Don't use global static QIcon's, they crash Qt5 on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 12, 2016
1 parent 0adae36 commit ca0bf6f
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 49 deletions.
2 changes: 0 additions & 2 deletions src/core/qgsdataitem.cpp
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdataitem.h
Expand Up @@ -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:
Expand Down
10 changes: 2 additions & 8 deletions src/gui/qgscollapsiblegroupbox.cpp
Expand Up @@ -27,9 +27,6 @@
#include <QSettings>
#include <QScrollArea>

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

QgsCollapsibleGroupBoxBasic::QgsCollapsibleGroupBoxBasic( QWidget *parent )
: QGroupBox( parent )
{
Expand Down Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgscollapsiblegroupbox.h
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/gui/qgsdatadefinedbutton.cpp
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsdatadefinedbutton.h
Expand Up @@ -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;
Expand Down
19 changes: 0 additions & 19 deletions src/gui/qgsfieldmodel.cpp
Expand Up @@ -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();

Expand Down
2 changes: 0 additions & 2 deletions src/gui/qgsvariableeditorwidget.cpp
Expand Up @@ -247,8 +247,6 @@ void QgsVariableEditorWidget::selectionChanged()
// VariableEditorTree
//

QIcon QgsVariableEditorTree::mExpandIcon;

QgsVariableEditorTree::QgsVariableEditorTree( QWidget *parent )
: QTreeWidget( parent )
, mEditorDelegate( nullptr )
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsvariableeditorwidget.h
Expand Up @@ -187,7 +187,7 @@ class QgsVariableEditorTree : public QTreeWidget

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

static QIcon mExpandIcon;
QIcon mExpandIcon;

private:

Expand Down

4 comments on commit ca0bf6f

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on ca0bf6f Apr 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

@m-kuhn m-kuhn commented on ca0bf6f Apr 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.