mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix plugins item double free
Change-Id: I50362a13e197e9b9e40f8bd680a9e8ac47fd98a4
This commit is contained in:
parent
51ee4140bb
commit
b1412526b3
Notes:
Deepin Code Review
2017-11-08 18:24:45 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Wed, 08 Nov 2017 18:24:44 +0800 Reviewed-on: https://cr.deepin.io/28113 Project: dde/dde-dock Branch: refs/heads/master
@ -38,11 +38,6 @@ DockItemController *DockItemController::instance(QObject *parent)
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
DockItemController::~DockItemController()
|
||||
{
|
||||
qDeleteAll(m_itemList);
|
||||
}
|
||||
|
||||
const QList<DockItem *> DockItemController::itemList() const
|
||||
{
|
||||
return m_itemList;
|
||||
@ -274,8 +269,8 @@ void DockItemController::appItemRemoved(const QString &appId)
|
||||
void DockItemController::appItemRemoved(AppItem *appItem)
|
||||
{
|
||||
emit itemRemoved(appItem);
|
||||
appItem->deleteLater();
|
||||
m_itemList.removeOne(appItem);
|
||||
appItem->deleteLater();
|
||||
}
|
||||
|
||||
void DockItemController::pluginItemInserted(PluginsItem *item)
|
||||
|
@ -39,7 +39,6 @@ class DockItemController : public QObject
|
||||
|
||||
public:
|
||||
static DockItemController *instance(QObject *parent);
|
||||
~DockItemController();
|
||||
|
||||
const QList<DockItem *> itemList() const;
|
||||
const QList<PluginsItemInterface *> pluginList() const;
|
||||
|
@ -38,10 +38,6 @@ DockPluginsController::DockPluginsController(DockItemController *itemControllerI
|
||||
QTimer::singleShot(1, this, &DockPluginsController::startLoader);
|
||||
}
|
||||
|
||||
DockPluginsController::~DockPluginsController()
|
||||
{
|
||||
}
|
||||
|
||||
void DockPluginsController::itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey)
|
||||
{
|
||||
// check if same item added
|
||||
@ -80,7 +76,7 @@ void DockPluginsController::itemRemoved(PluginsItemInterface * const itemInter,
|
||||
emit pluginItemRemoved(item);
|
||||
|
||||
m_pluginList[itemInter].remove(itemKey);
|
||||
QTimer::singleShot(1, item, &PluginsItem::deleteLater);
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
//void DockPluginsController::requestRefershWindowVisible()
|
||||
@ -138,7 +134,7 @@ void DockPluginsController::positionChanged()
|
||||
|
||||
void DockPluginsController::loadPlugin(const QString &pluginFile)
|
||||
{
|
||||
QPluginLoader *pluginLoader = new QPluginLoader(pluginFile, this);
|
||||
QPluginLoader *pluginLoader = new QPluginLoader(pluginFile);
|
||||
const auto meta = pluginLoader->metaData().value("MetaData").toObject();
|
||||
if (!meta.contains("api") || meta["api"].toString() != API_VERSION)
|
||||
{
|
||||
|
@ -39,7 +39,6 @@ class DockPluginsController : public QObject, PluginProxyInterface
|
||||
|
||||
public:
|
||||
explicit DockPluginsController(DockItemController *itemControllerInter = 0);
|
||||
~DockPluginsController();
|
||||
|
||||
// implements PluginProxyInterface
|
||||
void itemAdded(PluginsItemInterface * const itemInter, const QString &itemKey);
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
Position DockItem::DockPosition = Position::Top;
|
||||
DisplayMode DockItem::DockDisplayMode = DisplayMode::Efficient;
|
||||
std::unique_ptr<DockPopupWindow> DockItem::PopupWindow(nullptr);
|
||||
QPointer<DockPopupWindow> DockItem::PopupWindow(nullptr);
|
||||
|
||||
DockItem::DockItem(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
@ -40,7 +40,7 @@ DockItem::DockItem(QWidget *parent)
|
||||
|
||||
m_menuManagerInter(new DBusMenuManager(this))
|
||||
{
|
||||
if (!PopupWindow.get())
|
||||
if (PopupWindow.isNull())
|
||||
{
|
||||
DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr);
|
||||
arrowRectangle->setShadowBlurRadius(20);
|
||||
@ -51,7 +51,7 @@ DockItem::DockItem(QWidget *parent)
|
||||
arrowRectangle->setShadowXOffset(0);
|
||||
arrowRectangle->setArrowWidth(18);
|
||||
arrowRectangle->setArrowHeight(10);
|
||||
PopupWindow.reset(arrowRectangle);
|
||||
PopupWindow = arrowRectangle;
|
||||
}
|
||||
|
||||
m_popupTipsDelayTimer->setInterval(500);
|
||||
@ -215,7 +215,7 @@ void DockItem::showPopupWindow(QWidget * const content, const bool model)
|
||||
if (model)
|
||||
emit requestWindowAutoHide(false);
|
||||
|
||||
DockPopupWindow *popup = PopupWindow.get();
|
||||
DockPopupWindow *popup = PopupWindow.data();
|
||||
QWidget *lastContent = popup->getContent();
|
||||
if (lastContent)
|
||||
lastContent->setVisible(false);
|
||||
@ -244,7 +244,7 @@ void DockItem::popupWindowAccept()
|
||||
if (!PopupWindow->isVisible())
|
||||
return;
|
||||
|
||||
disconnect(PopupWindow.get(), &DockPopupWindow::accept, this, &DockItem::popupWindowAccept);
|
||||
disconnect(PopupWindow.data(), &DockPopupWindow::accept, this, &DockItem::popupWindowAccept);
|
||||
|
||||
hidePopup();
|
||||
|
||||
|
@ -100,7 +100,7 @@ protected:
|
||||
|
||||
static Position DockPosition;
|
||||
static DisplayMode DockDisplayMode;
|
||||
static std::unique_ptr<DockPopupWindow> PopupWindow;
|
||||
static QPointer<DockPopupWindow> PopupWindow;
|
||||
};
|
||||
|
||||
#endif // DOCKITEM_H
|
||||
|
@ -45,12 +45,6 @@ DatetimePlugin::DatetimePlugin(QObject *parent)
|
||||
connect(m_refershTimer, &QTimer::timeout, this, &DatetimePlugin::updateCurrentTimeString);
|
||||
}
|
||||
|
||||
DatetimePlugin::~DatetimePlugin()
|
||||
{
|
||||
delete m_centralWidget;
|
||||
delete m_dateTipsLabel;
|
||||
}
|
||||
|
||||
const QString DatetimePlugin::pluginName() const
|
||||
{
|
||||
return "datetime";
|
||||
|
@ -36,7 +36,6 @@ class DatetimePlugin : public QObject, PluginsItemInterface
|
||||
|
||||
public:
|
||||
explicit DatetimePlugin(QObject *parent = 0);
|
||||
~DatetimePlugin();
|
||||
|
||||
const QString pluginName() const override;
|
||||
const QString pluginDisplayName() const override;
|
||||
@ -60,8 +59,8 @@ private slots:
|
||||
void updateCurrentTimeString();
|
||||
|
||||
private:
|
||||
DatetimeWidget *m_centralWidget;
|
||||
QLabel *m_dateTipsLabel;
|
||||
QPointer<DatetimeWidget> m_centralWidget;
|
||||
QPointer<QLabel> m_dateTipsLabel;
|
||||
|
||||
QTimer *m_refershTimer;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user