Commit 28d72550 authored by Friedemann Kleint's avatar Friedemann Kleint

Removed static QIcon instances.

thus fixing the exit warning:
"~QX11PixmapData(): QPixmap objects must be destroyed..."

Acked-by: con
parent a403c436
......@@ -114,16 +114,16 @@ PluginSpec *PluginView::currentPlugin() const
void PluginView::updateList()
{
static QIcon okIcon(":/extensionsystem/images/ok.png");
static QIcon errorIcon(":/extensionsystem/images/error.png");
const QIcon okIcon(QLatin1String(":/extensionsystem/images/ok.png"));
const QIcon errorIcon(QLatin1String(":/extensionsystem/images/error.png"));
QList<QTreeWidgetItem *> items;
QTreeWidgetItem *currentItem = 0;
PluginSpec *currPlugin = currentPlugin();
foreach (PluginSpec *spec, p->manager->plugins()) {
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList()
<< ""
<< QString()
<< spec->name()
<< QString("%1 (%2)").arg(spec->version()).arg(spec->compatVersion())
<< QString::fromLatin1("%1 (%2)").arg(spec->version(), spec->compatVersion())
<< spec->vendor()
<< QDir::toNativeSeparators(spec->filePath()));
item->setToolTip(4, QDir::toNativeSeparators(spec->filePath()));
......
......@@ -375,9 +375,6 @@ void EditorView::checkEditorStatus()
void EditorView::updateEditorStatus(IEditor *editor)
{
static const QIcon lockedIcon(QLatin1String(":/core/images/locked.png"));
static const QIcon unlockedIcon(QLatin1String(":/core/images/unlocked.png"));
m_lockButton->setVisible(editor != 0);
if (!editor) {
......@@ -386,11 +383,11 @@ void EditorView::updateEditorStatus(IEditor *editor)
}
if (editor->file()->isReadOnly()) {
m_lockButton->setIcon(lockedIcon);
m_lockButton->setIcon(m_model->lockedIcon());
m_lockButton->setEnabled(!editor->file()->fileName().isEmpty());
m_lockButton->setToolTip(tr("Make writable"));
} else {
m_lockButton->setIcon(unlockedIcon);
m_lockButton->setIcon(m_model->unlockedIcon());
m_lockButton->setEnabled(false);
m_lockButton->setToolTip(tr("File is writable"));
}
......
......@@ -38,6 +38,23 @@ Q_DECLARE_METATYPE(Core::IEditor*)
namespace Core {
OpenEditorsModel::OpenEditorsModel(QObject *parent) :
QAbstractItemModel(parent),
m_lockedIcon(QLatin1String(":/core/images/locked.png")),
m_unlockedIcon(QLatin1String(":/core/images/unlocked.png"))
{
}
QIcon OpenEditorsModel::lockedIcon() const
{
return m_lockedIcon;
}
QIcon OpenEditorsModel::unlockedIcon() const
{
return m_unlockedIcon;
}
QString OpenEditorsModel::Entry::fileName() const {
return editor ? editor->file()->fileName() : m_fileName;
}
......@@ -265,8 +282,7 @@ QVariant OpenEditorsModel::data(const QModelIndex &index, int role) const
: e.displayName();
case Qt::DecorationRole:
return (e.editor && e.editor->file()->isReadOnly())
? QIcon(QLatin1String(":/core/images/locked.png"))
: QIcon();
? m_lockedIcon : QIcon();
case Qt::ToolTipRole:
return e.fileName().isEmpty()
? e.displayName()
......
......@@ -33,6 +33,7 @@
#include "../core_global.h"
#include <QtCore/QAbstractItemModel>
#include <QtGui/QIcon>
namespace Core {
......@@ -43,7 +44,11 @@ class CORE_EXPORT OpenEditorsModel : public QAbstractItemModel
{
Q_OBJECT
public:
OpenEditorsModel(QObject *parent) : QAbstractItemModel(parent) {}
explicit OpenEditorsModel(QObject *parent);
QIcon lockedIcon() const;
QIcon unlockedIcon() const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QModelIndex parent(const QModelIndex &/*index*/) const { return QModelIndex(); }
......@@ -91,6 +96,10 @@ private:
void addEntry(const Entry &entry);
int findEditor(IEditor *editor) const;
int findFileName(const QString &filename) const;
const QIcon m_lockedIcon;
const QIcon m_unlockedIcon;
QList<Entry> m_editors;
QList<IEditor *>m_duplicateEditors;
};
......
......@@ -35,6 +35,8 @@
#include <utils/qtcassert.h>
#include <QtGui/QHeaderView>
#include <QtGui/QTreeWidget>
#include <QtGui/QFocusEvent>
Q_DECLARE_METATYPE(Core::Internal::EditorView*)
Q_DECLARE_METATYPE(Core::IFile *)
......@@ -48,6 +50,7 @@ const int OpenEditorsWindow::MARGIN = 4;
OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
QWidget(parent, Qt::Popup),
m_emptyIcon(QLatin1String(":/core/images/empty14.png")),
m_editorList(new QTreeWidget(this))
{
resize(QSize(WIDTH, HEIGHT));
......@@ -184,9 +187,6 @@ void OpenEditorsWindow::centerOnItem(int selectedIndex)
void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenEditorsModel *model)
{
static const QIcon lockedIcon(QLatin1String(":/core/images/locked.png"));
static const QIcon emptyIcon(QLatin1String(":/core/images/empty14.png"));
m_editorList->clear();
bool first = true;
......@@ -200,7 +200,7 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
QTreeWidgetItem *item = new QTreeWidgetItem();
if (hi.file->isModified())
title += tr("*");
item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon);
item->setIcon(0, hi.file->isReadOnly() ? model->lockedIcon() : m_emptyIcon);
item->setText(0, title);
item->setToolTip(0, hi.file->fileName());
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
......@@ -227,7 +227,7 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
QString title = model->displayNameForFile(hi.file);
if (hi.file->isModified())
title += tr("*");
item->setIcon(0, hi.file->isReadOnly() ? lockedIcon : emptyIcon);
item->setIcon(0, hi.file->isReadOnly() ? model->lockedIcon() : m_emptyIcon);
item->setText(0, title);
item->setToolTip(0, hi.file->fileName());
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
......@@ -250,7 +250,7 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
continue;
QTreeWidgetItem *item = new QTreeWidgetItem();
QString title = entry.displayName();
item->setIcon(0, emptyIcon);
item->setIcon(0, m_emptyIcon);
item->setText(0, title);
item->setToolTip(0, entry.fileName());
item->setData(0, Qt::UserRole+2, QVariant::fromValue(entry.id()));
......
......@@ -30,12 +30,13 @@
#ifndef OPENEDITORSWINDOW_H
#define OPENEDITORSWINDOW_H
#include <QtCore/QTimer>
#include <QtGui/QWidget>
#include <QtGui/QKeyEvent>
#include <QtGui/QFocusEvent>
#include <QtGui/QTreeWidget>
#include <QtDebug>
#include <QtGui/QIcon>
QT_BEGIN_NAMESPACE
class QTreeWidgetItem;
class QTreeWidget;
QT_END_NAMESPACE
namespace Core {
......@@ -54,8 +55,7 @@ class OpenEditorsWindow : public QWidget
public:
enum Mode {ListMode, HistoryMode };
OpenEditorsWindow(QWidget *parent = 0);
~OpenEditorsWindow() {}
explicit OpenEditorsWindow(QWidget *parent = 0);
void setEditors(EditorView *mainView, EditorView *view, OpenEditorsModel *model);
......@@ -85,6 +85,7 @@ private:
bool isSameFile(IEditor *editorA, IEditor *editorB) const;
const QIcon m_emptyIcon;
QTreeWidget *m_editorList;
};
......
......@@ -99,14 +99,7 @@ bool panelWidget(const QWidget *widget)
class ManhattanStylePrivate
{
public:
ManhattanStylePrivate(const QString &baseStyleName)
{
style = QStyleFactory::create(baseStyleName);
QTC_ASSERT(style, /**/);
lineeditImage = QImage(":/core/images/inputfield.png");
lineeditImage_disabled = QImage(":/core/images/inputfield_disabled.png");
}
explicit ManhattanStylePrivate(const QString &baseStyleName);
~ManhattanStylePrivate()
{
......@@ -118,12 +111,23 @@ public:
public:
QStyle *style;
QImage lineeditImage;
QImage lineeditImage_disabled;
const QImage lineeditImage;
const QImage lineeditImage_disabled;
const QPixmap extButtonPixmap;
const QPixmap closeButtonPixmap;
StyleAnimator animator;
};
ManhattanStylePrivate::ManhattanStylePrivate(const QString &baseStyleName) :
style(QStyleFactory::create(baseStyleName)),
lineeditImage(QLatin1String(":/core/images/inputfield.png")),
lineeditImage_disabled(QLatin1String(":/core/images/inputfield_disabled.png")),
extButtonPixmap(QLatin1String(":/core/images/extension.png")),
closeButtonPixmap(QLatin1String(":/core/images/closebutton.png"))
{
QTC_ASSERT(style, /**/);
}
ManhattanStyle::ManhattanStyle(const QString &baseStyleName)
: QWindowsStyle(), d(new ManhattanStylePrivate(baseStyleName))
{
......@@ -376,23 +380,19 @@ QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QSty
QPixmap pixmap;
switch (standardPixmap) {
case QStyle::SP_ToolBarHorizontalExtensionButton: {
static const QPixmap extButton(":/core/images/extension.png");
pixmap = extButton;
}
case QStyle::SP_ToolBarHorizontalExtensionButton:
pixmap = d->extButtonPixmap;
break;
case QStyle::SP_TitleBarCloseButton: {
static const QPixmap closeButton(":/core/images/closebutton.png");
pixmap = closeButton;
}
case QStyle::SP_TitleBarCloseButton:
pixmap = d->closeButtonPixmap;
break;
default:
pixmap = d->style->standardPixmap(standardPixmap, opt, widget);
break;
}
return pixmap;
}
int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
QStyleHintReturn *returnData) const
{
......
......@@ -86,15 +86,10 @@ public:
QIcon icon() const
{
return icon(m_pending, m_enabled);
}
static const QIcon &icon(bool pending, bool enabled)
{
static const QIcon icon(":/debugger/images/breakpoint.svg");
static const QIcon icon1(":/debugger/images/breakpoint_disabled.svg");
static const QIcon icon2(":/debugger/images/breakpoint_pending.svg");
return enabled ? (pending ? icon2 : icon) : icon1;
const BreakHandler *handler = DebuggerManager::instance()->breakHandler();
if (!m_enabled)
return handler->disabledBreakpointIcon();
return m_pending ? handler->pendingBreakPointIcon() : handler->breakpointIcon();
}
void setPending(bool pending, bool enabled)
......@@ -289,9 +284,14 @@ bool BreakpointData::conditionsMatch() const
//
//////////////////////////////////////////////////////////////////
BreakHandler::BreakHandler(DebuggerManager *manager, QObject *parent)
: QAbstractTableModel(parent), m_manager(manager)
{}
BreakHandler::BreakHandler(DebuggerManager *manager, QObject *parent) :
QAbstractTableModel(parent),
m_breakpointIcon(QLatin1String(":/debugger/images/breakpoint.svg")),
m_disabledBreakpointIcon(QLatin1String(":/debugger/images/breakpoint_disabled.svg")),
m_pendingBreakPointIcon(QLatin1String(":/debugger/images/breakpoint_pending.svg")),
m_manager(manager)
{
}
BreakHandler::~BreakHandler()
{
......@@ -488,19 +488,20 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
switch (mi.column()) {
case 0:
if (role == Qt::DisplayRole) {
QString str = data->bpNumber;
const QString str = data->bpNumber;
return str.isEmpty() ? empty : str;
}
//if (role == Qt::CheckStateRole)
// return data->enabled ? Qt::Checked : Qt::Unchecked;
if (role == Qt::UserRole)
return data->enabled;
if (role == Qt::DecorationRole)
return BreakpointMarker::icon(data->pending, data->enabled);
if (role == Qt::DecorationRole) {
if (!data->enabled)
return m_disabledBreakpointIcon;
return data->pending ? m_pendingBreakPointIcon : m_breakpointIcon;
}
break;
case 1:
if (role == Qt::DisplayRole) {
QString str = data->pending ? data->funcName : data->bpFuncName;
const QString str = data->pending ? data->funcName : data->bpFuncName;
return str.isEmpty() ? empty : str;
}
break;
......@@ -508,8 +509,6 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
if (role == Qt::DisplayRole) {
QString str = data->pending ? data->fileName : data->bpFileName;
str = QFileInfo(str).fileName();
//if (data->bpMultiple && str.isEmpty() && !data->markerFileName.isEmpty())
// str = data->markerFileName;
str = str.isEmpty() ? empty : str;
if (data->useFullPath)
str = "/.../" + str;
......@@ -520,9 +519,7 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
break;
case 3:
if (role == Qt::DisplayRole) {
QString str = data->pending ? data->lineNumber : data->bpLineNumber;
//if (data->bpMultiple && str.isEmpty() && !data->markerFileName.isEmpty())
// str = data->markerLineNumber;
const QString str = data->pending ? data->lineNumber : data->bpLineNumber;
return str.isEmpty() ? empty : str;
}
break;
......
......@@ -34,6 +34,7 @@
#include <QtCore/QObject>
#include <QtCore/QAbstractTableModel>
#include <QtGui/QIcon>
namespace Debugger {
class DebuggerManager;
......@@ -143,6 +144,10 @@ public:
QList<BreakpointData *> takeEnabledBreakpoints(); // not owned
QList<BreakpointData *> takeDisabledBreakpoints(); // not owned
QIcon breakpointIcon() const { return m_breakpointIcon; }
QIcon disabledBreakpointIcon() const { return m_disabledBreakpointIcon; }
QIcon pendingBreakPointIcon() const { return m_pendingBreakPointIcon; }
public slots:
void setBreakpoint(const QString &fileName, int lineNumber);
void toggleBreakpointEnabled(BreakpointData *data);
......@@ -168,6 +173,10 @@ private:
void resetBreakpoints();
void removeBreakpointHelper(int index);
const QIcon m_breakpointIcon;
const QIcon m_disabledBreakpointIcon;
const QIcon m_pendingBreakPointIcon;
DebuggerManager *m_manager; // not owned
QList<BreakpointData *> m_bp;
QList<BreakpointData *> m_inserted; // lately inserted breakpoints
......
......@@ -132,19 +132,13 @@ void MemoryViewAgent::addLazyData(quint64 addr, const QByteArray &ba)
//
///////////////////////////////////////////////////////////////////////
static QIcon locationMarkIcon()
{
static const QIcon icon(":/debugger/images/location.svg");
return icon;
}
// Used for the disassembler view
class LocationMark2 : public TextEditor::ITextMark
{
public:
LocationMark2() {}
QIcon icon() const { return locationMarkIcon(); }
QIcon icon() const { return DebuggerManager::instance()->locationMarkIcon(); }
void updateLineNumber(int /*lineNumber*/) {}
void updateBlock(const QTextBlock & /*block*/) {}
void removedFromEditor() {}
......
......@@ -247,10 +247,14 @@ static Debugger::Internal::IDebuggerEngine *winEngine = 0;
struct DebuggerManagerPrivate
{
DebuggerManagerPrivate(DebuggerManager *manager);
explicit DebuggerManagerPrivate(DebuggerManager *manager);
static DebuggerManager *instance;
const QIcon m_stopSmallIcon;
const QIcon m_interruptSmallIcon;
const QIcon m_locationMarkIcon;
// FIXME: Remove engine-specific state
DebuggerStartParametersPtr m_startParameters;
qint64 m_inferiorPid;
......@@ -303,12 +307,15 @@ struct DebuggerManagerPrivate
DebuggerManager *DebuggerManagerPrivate::instance = 0;
DebuggerManagerPrivate::DebuggerManagerPrivate(DebuggerManager *manager)
: m_startParameters(new DebuggerStartParameters),
m_disassemblerViewAgent(manager),
m_engine(0)
DebuggerManagerPrivate::DebuggerManagerPrivate(DebuggerManager *manager) :
m_stopSmallIcon(QLatin1String(":/debugger/images/debugger_stop_small.png")),
m_interruptSmallIcon(QLatin1String(":/debugger/images/debugger_interrupt_small.png")),
m_locationMarkIcon(QLatin1String(":/debugger/images/location.svg")),
m_startParameters(new DebuggerStartParameters),
m_inferiorPid(0),
m_disassemblerViewAgent(manager),
m_engine(0)
{
m_inferiorPid = 0;
}
DebuggerManager::DebuggerManager()
......@@ -460,7 +467,7 @@ void DebuggerManager::init()
d->m_actions.continueAction->setIcon(QIcon(":/debugger/images/debugger_continue_small.png"));
d->m_actions.stopAction = new QAction(tr("Interrupt"), this);
d->m_actions.stopAction->setIcon(QIcon(":/debugger/images/debugger_interrupt_small.png"));
d->m_actions.stopAction->setIcon(d->m_interruptSmallIcon);
d->m_actions.resetAction = new QAction(tr("Reset Debugger"), this);
......@@ -1736,12 +1743,10 @@ void DebuggerManager::setState(DebuggerState state, bool forced)
const bool interruptIsExit = !running;
if (interruptIsExit) {
static QIcon icon(":/debugger/images/debugger_stop_small.png");
d->m_actions.stopAction->setIcon(icon);
d->m_actions.stopAction->setIcon(d->m_stopSmallIcon);
d->m_actions.stopAction->setText(tr("Stop Debugger"));
} else {
static QIcon icon(":/debugger/images/debugger_interrupt_small.png");
d->m_actions.stopAction->setIcon(icon);
d->m_actions.stopAction->setIcon(d->m_interruptSmallIcon);
d->m_actions.stopAction->setText(tr("Interrupt"));
}
......@@ -1860,6 +1865,11 @@ void DebuggerManager::ensureLogVisible()
action->trigger();
}
QIcon DebuggerManager::locationMarkIcon() const
{
return d->m_locationMarkIcon;
}
QDebug operator<<(QDebug d, DebuggerState state)
{
return d << DebuggerManager::stateName(state) << '(' << int(state) << ')';
......
......@@ -47,6 +47,7 @@ class QLabel;
class QMessageBox;
class QPoint;
class QVariant;
class QIcon;
QT_END_NAMESPACE
namespace Core {
......@@ -97,6 +98,7 @@ class GdbEngine;
class CdbDebugEngine;
class CdbDebugEnginePrivate;
class TrkGdbAdapter;
class BreakpointMarker;
} // namespace Internal
class DEBUGGER_EXPORT DebuggerStartParameters
......@@ -173,6 +175,7 @@ public:
friend class Internal::CdbDebugEngine;
friend class Internal::CdbDebugEnginePrivate;
friend class Internal::TrkGdbAdapter;
friend class Internal::BreakpointMarker;
DebuggerState state() const;
QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
......@@ -197,6 +200,8 @@ public:
const CPlusPlus::Snapshot &cppCodeModelSnapshot() const;
QIcon locationMarkIcon() const;
static DebuggerManager *instance();
public slots:
......
......@@ -280,12 +280,6 @@ bool DebuggerListener::coreAboutToClose()
namespace Debugger {
namespace Internal {
static QIcon locationMarkIcon()
{
static const QIcon icon(":/debugger/images/location.svg");
return icon;
}
// Used in "real" editors
class LocationMark : public TextEditor::BaseTextMark
{
......@@ -296,7 +290,7 @@ public:
: BaseTextMark(fileName, linenumber)
{}
QIcon icon() const { return locationMarkIcon(); }
QIcon icon() const { return DebuggerManager::instance()->locationMarkIcon(); }
void updateLineNumber(int /*lineNumber*/) {}
void updateBlock(const QTextBlock & /*block*/) {}
void removedFromEditor() {}
......
......@@ -131,7 +131,7 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
default:
break;
}
if (const ProjectExplorer::Project *project = runConfiguration->target()->project()) {
if (runConfiguration->target()->project()) {
m_startParameters->buildDir =
runConfiguration->target()->activeBuildConfiguration()->buildDirectory();
}
......
......@@ -96,9 +96,6 @@ QVariant ModulesModel::headerData(int section,
QVariant ModulesModel::data(const QModelIndex &index, int role) const
{
//static const QIcon icon(":/debugger/images/breakpoint.svg");
//static const QIcon icon2(":/debugger/images/breakpoint_pending.svg");
int row = index.row();
if (row < 0 || row >= m_modules.size())
return QVariant();
......
......@@ -113,9 +113,6 @@ Qt::ItemFlags SourceFilesModel::flags(const QModelIndex &index) const
QVariant SourceFilesModel::data(const QModelIndex &index, int role) const
{
//static const QIcon icon(":/gdbdebugger/images/breakpoint.svg");
//static const QIcon icon2(":/gdbdebugger/images/breakpoint_pending.svg");
int row = index.row();
if (row < 0 || row >= m_shortNames.size())
return QVariant();
......
......@@ -56,6 +56,9 @@ static void drawSecondLevelSeparator(QPainter *painter, QPoint top, QPoint botto
DoubleTabWidget::DoubleTabWidget(QWidget *parent) :
QWidget(parent),
m_left(QLatin1String(":/projectexplorer/images/leftselection.png")),
m_mid(QLatin1String(":/projectexplorer/images/midselection.png")),
m_right(QLatin1String(":/projectexplorer/images/rightselection.png")),
ui(new Ui::DoubleTabWidget),
m_currentIndex(-1),
m_lastVisibleIndex(-1)
......@@ -358,12 +361,9 @@ void DoubleTabWidget::paintEvent(QPaintEvent *event)
}
// second level tabs
static QPixmap left(":/projectexplorer/images/leftselection.png");
static QPixmap mid(":/projectexplorer/images/midselection.png");
static QPixmap right(":/projectexplorer/images/rightselection.png");
if (m_currentIndex != -1) {
int y = r.height() + (OTHER_HEIGHT - left.height()) / 2.;
int imageHeight = left.height();
int y = r.height() + (OTHER_HEIGHT - m_left.height()) / 2.;
int imageHeight = m_left.height();
Tab currentTab = m_tabs.at(m_currentIndex);
QStringList subTabs = currentTab.subTabs;
x = 0;
......@@ -372,11 +372,11 @@ void DoubleTabWidget::paintEvent(QPaintEvent *event)
int textWidth = fm.width(subTabs.at(i));
if (currentTab.currentSubTab == i) {
painter.setPen(Qt::white);
painter.drawPixmap(x, y, left);
painter.drawPixmap(x, y, m_left);
painter.drawPixmap(QRect(x + SELECTION_IMAGE_WIDTH, y,
textWidth, imageHeight),
mid, QRect(0, 0, mid.width(), mid.height()));
painter.drawPixmap(x + SELECTION_IMAGE_WIDTH + textWidth, y, right);
m_mid, QRect(0, 0, m_mid.width(), m_mid.height()));
painter.drawPixmap(x + SELECTION_IMAGE_WIDTH + textWidth, y, m_right);
} else {
painter.setPen(Qt::black);
}
......
......@@ -3,6 +3,7 @@
#include <QtCore/QVector>
#include <QtGui/QWidget>
#include <QtGui/QPixmap>
namespace ProjectExplorer {
namespace Internal {
......@@ -41,8 +42,13 @@ private:
int currentSubTab;
};
const QPixmap m_left;
const QPixmap m_mid;
const QPixmap m_right;
Ui::DoubleTabWidget *ui;