Commit 21aa9285 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Don't crash in the thememanager when creating a second document

Okay, not so drop-in as I thought :-). Digikam uses the thememanager as
a per-app object, we use it per-view, so when the view is killed, the
actions are killed, but the thememanager singleton wasn't informed.

Create and teardown the thememanager in the view now.

BUG:296887
parent 4a90a513
......@@ -162,8 +162,9 @@ public:
, imageManager(0)
, gridManager(0)
, perspectiveGridManager(0)
, paintingAssistantManager(0) {
, paintingAssistantManager(0)
, themeManager(0)
{
}
~KisView2Private() {
......@@ -209,6 +210,7 @@ public:
KisPaintingAssistantsManager* paintingAssistantManager;
KoFavoriteResourceManager* favoriteResourceManager;
BlockingUserInputEventFilter blockingEventFilter;
Digikam::ThemeManager *themeManager;
};
......@@ -217,7 +219,7 @@ KisView2::KisView2(KisDoc2 * doc, QWidget * parent)
m_d(new KisView2Private())
{
// populate theme menu
Digikam::ThemeManager::instance();
m_d->themeManager = new Digikam::ThemeManager(this);
setFocusPolicy(Qt::NoFocus);
......@@ -411,7 +413,7 @@ KisView2::KisView2(KisDoc2 * doc, QWidget * parent)
KisView2::~KisView2()
{
KConfigGroup group(KGlobal::config(), "theme");
group.writeEntry("Theme", Digikam::ThemeManager::instance()->currentThemeName());
group.writeEntry("Theme", m_d->themeManager->currentThemeName());
delete m_d;
}
......@@ -723,10 +725,10 @@ void KisView2::createActions()
connect(action, SIGNAL(triggered()), this, SLOT(slotEditPalette()));
KConfigGroup group(KGlobal::config(), "theme");
Digikam::ThemeManager::instance()->setThemeMenuAction(new KActionMenu(i18n("&Themes"), this));
Digikam::ThemeManager::instance()->registerThemeActions(actionCollection());
Digikam::ThemeManager::instance()->setCurrentTheme(group.readEntry("Theme",
Digikam::ThemeManager::instance()->defaultThemeName()));
m_d->themeManager->setThemeMenuAction(new KActionMenu(i18n("&Themes"), this));
m_d->themeManager->registerThemeActions(actionCollection());
m_d->themeManager->setCurrentTheme(group.readEntry("Theme",
m_d->themeManager->defaultThemeName()));
}
......
......@@ -59,15 +59,6 @@
namespace Digikam
{
class ThemeManagerCreator
{
public:
ThemeManager object;
};
K_GLOBAL_STATIC(ThemeManagerCreator, creator)
// ---------------------------------------------------------------
......@@ -89,8 +80,9 @@ public:
KActionMenu* themeMenuAction;
};
ThemeManager::ThemeManager()
: d(new ThemeManagerPriv)
ThemeManager::ThemeManager(QObject *parent)
: QObject(parent)
, d(new ThemeManagerPriv)
{
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
this, SLOT(slotSettingsChanged()));
......@@ -101,11 +93,6 @@ ThemeManager::~ThemeManager()
delete d;
}
ThemeManager* ThemeManager::instance()
{
return &creator->object;
}
QString ThemeManager::defaultThemeName() const
{
return d->defaultThemeName;
......@@ -114,6 +101,7 @@ QString ThemeManager::defaultThemeName() const
QString ThemeManager::currentThemeName() const
{
if (!d->themeMenuAction || !d->themeMenuActionGroup) return defaultThemeName();
qDebug() << d->themeMenuActionGroup;
QAction* action = d->themeMenuActionGroup->checkedAction();
return !action ? defaultThemeName() : action->text().remove('&');
}
......
......@@ -48,8 +48,8 @@ class ThemeManager : public QObject
public:
ThemeManager(QObject *parent);
~ThemeManager();
static ThemeManager* instance();
QString currentThemeName() const;
void setCurrentTheme(const QString& name);
......@@ -71,7 +71,6 @@ private Q_SLOTS:
private:
ThemeManager();
void populateThemeMenu();
QPixmap createSchemePreviewIcon(const KSharedConfigPtr& config);
......@@ -80,8 +79,6 @@ private:
private:
friend class ThemeManagerCreator;
class ThemeManagerPriv;
ThemeManagerPriv* const d;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment