Help: Fix leaking side bar widget and find placeholder.

Breakage introduced by d28dc2d989.

Reviewed-by: con
This commit is contained in:
Friedemann Kleint
2011-03-03 16:46:57 +01:00
parent bbf464fd21
commit aa5b5e237c
4 changed files with 18 additions and 10 deletions

View File

@@ -128,7 +128,7 @@ void RightPanePlaceHolder::currentModeChanged(Core::IMode *mode)
RightPaneWidget *RightPaneWidget::m_instance = 0; RightPaneWidget *RightPaneWidget::m_instance = 0;
RightPaneWidget::RightPaneWidget() RightPaneWidget::RightPaneWidget()
: m_shown(true), m_width(0), m_widget(0) : m_shown(true), m_width(0)
{ {
m_instance = this; m_instance = this;

View File

@@ -37,6 +37,7 @@
#include "core_global.h" #include "core_global.h"
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtCore/QPointer>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QSettings; class QSettings;
@@ -93,7 +94,7 @@ private:
void clearWidget(); void clearWidget();
bool m_shown; bool m_shown;
int m_width; int m_width;
QWidget *m_widget; QPointer<QWidget> m_widget;
static RightPaneWidget *m_instance; static RightPaneWidget *m_instance;
}; };

View File

@@ -128,6 +128,7 @@ HelpPlugin::HelpPlugin()
: m_mode(0), : m_mode(0),
m_core(0), m_core(0),
m_centralWidget(0), m_centralWidget(0),
m_rightPaneSideBarWidget(0),
m_helpViewerForSideBar(0), m_helpViewerForSideBar(0),
m_contentItem(0), m_contentItem(0),
m_indexItem(0), m_indexItem(0),
@@ -145,6 +146,7 @@ HelpPlugin::HelpPlugin()
HelpPlugin::~HelpPlugin() HelpPlugin::~HelpPlugin()
{ {
delete m_rightPaneSideBarWidget;
} }
bool HelpPlugin::initialize(const QStringList &arguments, QString *error) bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
@@ -328,7 +330,9 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
if (QLayout *layout = m_centralWidget->layout()) { if (QLayout *layout = m_centralWidget->layout()) {
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(new Core::FindToolBarPlaceHolder(m_centralWidget)); Core::FindToolBarPlaceHolder *fth = new Core::FindToolBarPlaceHolder(m_centralWidget);
fth->setObjectName(QLatin1String("HelpFindToolBarPlaceHolder"));
layout->addWidget(fth);
} }
HelpIndexFilter *helpIndexFilter = new HelpIndexFilter(); HelpIndexFilter *helpIndexFilter = new HelpIndexFilter();
@@ -526,7 +530,7 @@ void HelpPlugin::resetFilter()
void HelpPlugin::createRightPaneContextViewer() void HelpPlugin::createRightPaneContextViewer()
{ {
if (m_helpViewerForSideBar) if (m_rightPaneSideBarWidget)
return; return;
Utils::StyledBar *toolBar = new Utils::StyledBar(); Utils::StyledBar *toolBar = new Utils::StyledBar();
@@ -553,21 +557,23 @@ void HelpPlugin::createRightPaneContextViewer()
layout->addStretch(); layout->addStretch();
layout->addWidget(toolButton(close)); layout->addWidget(toolButton(close));
QWidget *rightPaneSideBar = new QWidget; m_rightPaneSideBarWidget = new QWidget;
m_helpViewerForSideBar = new HelpViewer(qreal(0.0), rightPaneSideBar); m_helpViewerForSideBar = new HelpViewer(qreal(0.0));
connect(m_helpViewerForSideBar, SIGNAL(openFindToolBar()), this, connect(m_helpViewerForSideBar, SIGNAL(openFindToolBar()), this,
SLOT(openFindToolBar())); SLOT(openFindToolBar()));
#if !defined(QT_NO_WEBKIT) #if !defined(QT_NO_WEBKIT)
m_helpViewerForSideBar->pageAction(QWebPage::OpenLinkInNewWindow)->setVisible(false); m_helpViewerForSideBar->pageAction(QWebPage::OpenLinkInNewWindow)->setVisible(false);
#endif #endif
QVBoxLayout *rightPaneLayout = new QVBoxLayout(rightPaneSideBar); QVBoxLayout *rightPaneLayout = new QVBoxLayout(m_rightPaneSideBarWidget);
rightPaneLayout->setMargin(0); rightPaneLayout->setMargin(0);
rightPaneLayout->setSpacing(0); rightPaneLayout->setSpacing(0);
rightPaneLayout->addWidget(toolBar); rightPaneLayout->addWidget(toolBar);
rightPaneLayout->addWidget(m_helpViewerForSideBar); rightPaneLayout->addWidget(m_helpViewerForSideBar);
rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(rightPaneSideBar)); Core::FindToolBarPlaceHolder *fth = new Core::FindToolBarPlaceHolder(m_rightPaneSideBarWidget);
rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar); fth->setObjectName(QLatin1String("HelpRightPaneFindToolBarPlaceHolder"));
rightPaneLayout->addWidget(fth);
m_rightPaneSideBarWidget->setFocusProxy(m_helpViewerForSideBar);
Aggregation::Aggregate *agg = new Aggregation::Aggregate(); Aggregation::Aggregate *agg = new Aggregation::Aggregate();
agg->add(m_helpViewerForSideBar); agg->add(m_helpViewerForSideBar);
@@ -832,7 +838,7 @@ HelpViewer* HelpPlugin::viewerForContextMode()
} }
if (placeHolder && showSideBySide) { if (placeHolder && showSideBySide) {
RightPaneWidget::instance()->setWidget(m_helpViewerForSideBar->parentWidget()); RightPaneWidget::instance()->setWidget(m_rightPaneSideBarWidget);
RightPaneWidget::instance()->setShown(true); RightPaneWidget::instance()->setShown(true);
createRightPaneContextViewer(); createRightPaneContextViewer();
return m_helpViewerForSideBar; return m_helpViewerForSideBar;

View File

@@ -141,6 +141,7 @@ private:
HelpMode *m_mode; HelpMode *m_mode;
Core::ICore *m_core; Core::ICore *m_core;
CentralWidget *m_centralWidget; CentralWidget *m_centralWidget;
QWidget *m_rightPaneSideBarWidget;
HelpViewer *m_helpViewerForSideBar; HelpViewer *m_helpViewerForSideBar;
Core::SideBarItem *m_contentItem; Core::SideBarItem *m_contentItem;