Fix the coredump problem caused by nullpointer to UserIcon.
Fix some possible crash problems caused by sigc::slot. Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
This commit is contained in:
parent
ac4af27df1
commit
3cf2488e5a
204
0001-fix-connect-Fix-some-possible-crash-problems-caused-.patch
Normal file
204
0001-fix-connect-Fix-some-possible-crash-problems-caused-.patch
Normal file
@ -0,0 +1,204 @@
|
||||
From ee1e902961b07f16b22916338bc37b98ba9d9060 Mon Sep 17 00:00:00 2001
|
||||
From: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
Date: Tue, 9 Aug 2022 09:41:35 +0800
|
||||
Subject: [PATCH 1/2] fix(connect): Fix some possible crash problems caused by
|
||||
sigc::slot.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 修复一些可能存在的崩溃问题,这些崩溃问题是因为槽函数绑定的对象已经被释放导致
|
||||
|
||||
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
---
|
||||
src/menu/menu-app-item.cpp | 52 ++++++++++++++++++++------------
|
||||
src/menu/menu-app-item.h | 5 +++
|
||||
src/menu/menu-applet-window.cpp | 3 +-
|
||||
src/menu/menu-apps-container.cpp | 12 ++------
|
||||
src/menu/menu-apps-container.h | 7 -----
|
||||
5 files changed, 40 insertions(+), 39 deletions(-)
|
||||
|
||||
diff --git a/src/menu/menu-app-item.cpp b/src/menu/menu-app-item.cpp
|
||||
index fba3994..fa672c2 100644
|
||||
--- a/src/menu/menu-app-item.cpp
|
||||
+++ b/src/menu/menu-app-item.cpp
|
||||
@@ -68,11 +68,7 @@ void MenuAppItem::init_drag_and_drop()
|
||||
targets.push_back(target);
|
||||
drag_source_set(targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY);
|
||||
|
||||
- signal_drag_failed().connect(
|
||||
- [this](const Glib::RefPtr<Gdk::DragContext> &context, Gtk::DragResult result) -> bool {
|
||||
- KLOG_DEBUG("drag failed, result %d\n", (int)result);
|
||||
- return true;
|
||||
- });
|
||||
+ signal_drag_failed().connect(sigc::mem_fun(*this, &MenuAppItem::on_drag_failed));
|
||||
}
|
||||
|
||||
bool MenuAppItem::on_button_press_event(GdkEventButton *button_event)
|
||||
@@ -131,14 +127,22 @@ void MenuAppItem::on_drag_end(const Glib::RefPtr<Gdk::DragContext> &context)
|
||||
// 如果拖拽被取消,拖拽的ungrab操作可能在drag-end信号之后,所以这里的grab操作放入到后面的事件循环处理。
|
||||
if (this->idle_drag_connection_.empty())
|
||||
{
|
||||
- this->idle_drag_connection_ = Glib::signal_idle().connect([this]() -> bool {
|
||||
- Gtk::Container *toplevel = this->get_toplevel();
|
||||
- KiranHelper::grab_input(*toplevel);
|
||||
- return false;
|
||||
- });
|
||||
+ this->idle_drag_connection_ = Glib::signal_idle().connect(
|
||||
+ [this]() -> bool
|
||||
+ {
|
||||
+ Gtk::Container *toplevel = this->get_toplevel();
|
||||
+ KiranHelper::grab_input(*toplevel);
|
||||
+ return false;
|
||||
+ });
|
||||
}
|
||||
}
|
||||
|
||||
+bool MenuAppItem::on_drag_failed(const Glib::RefPtr<Gdk::DragContext> &context, Gtk::DragResult result)
|
||||
+{
|
||||
+ KLOG_DEBUG("drag failed, result %d\n", (int)result);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
bool MenuAppItem::on_key_press_event(GdkEventKey *key_event)
|
||||
{
|
||||
if (key_event->keyval == GDK_KEY_Menu)
|
||||
@@ -181,20 +185,12 @@ void MenuAppItem::create_context_menu()
|
||||
if (!is_in_favorite())
|
||||
{
|
||||
item = Gtk::make_managed<Gtk::MenuItem>(_("Add to favorites"));
|
||||
- item->signal_activate().connect(
|
||||
- [this]() -> void {
|
||||
- if (!app.expired())
|
||||
- Kiran::MenuSkeleton::get_instance()->add_favorite_app(app.lock()->get_desktop_id());
|
||||
- });
|
||||
+ item->signal_activate().connect(sigc::mem_fun(*this, &MenuAppItem::on_add_favorite_app));
|
||||
}
|
||||
else
|
||||
{
|
||||
item = Gtk::make_managed<Gtk::MenuItem>(_("Remove from favorites"));
|
||||
- item->signal_activate().connect(
|
||||
- [this]() -> void {
|
||||
- if (!app.expired())
|
||||
- Kiran::MenuSkeleton::get_instance()->del_favorite_app(app.lock()->get_desktop_id());
|
||||
- });
|
||||
+ item->signal_activate().connect(sigc::mem_fun(*this, &MenuAppItem::on_del_favorite_app));
|
||||
}
|
||||
context_menu.append(*item);
|
||||
|
||||
@@ -345,3 +341,19 @@ void MenuAppItem::launch_app()
|
||||
signal_launched().emit();
|
||||
app.lock()->launch();
|
||||
}
|
||||
+
|
||||
+void MenuAppItem::on_add_favorite_app()
|
||||
+{
|
||||
+ if (!this->app.expired())
|
||||
+ {
|
||||
+ Kiran::MenuSkeleton::get_instance()->add_favorite_app(app.lock()->get_desktop_id());
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void MenuAppItem::on_del_favorite_app()
|
||||
+{
|
||||
+ if (!app.expired())
|
||||
+ {
|
||||
+ Kiran::MenuSkeleton::get_instance()->del_favorite_app(app.lock()->get_desktop_id());
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/menu/menu-app-item.h b/src/menu/menu-app-item.h
|
||||
index 39f3767..6caadd7 100644
|
||||
--- a/src/menu/menu-app-item.h
|
||||
+++ b/src/menu/menu-app-item.h
|
||||
@@ -37,6 +37,7 @@ protected:
|
||||
virtual void on_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context) override;
|
||||
virtual void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext> &context, Gtk::SelectionData &selection, guint info, guint timestamp) override;
|
||||
virtual void on_drag_end(const Glib::RefPtr<Gdk::DragContext> &context) override;
|
||||
+ bool on_drag_failed(const Glib::RefPtr<Gdk::DragContext> &context, Gtk::DragResult result);
|
||||
|
||||
virtual void init_drag_and_drop();
|
||||
|
||||
@@ -46,6 +47,10 @@ protected:
|
||||
void create_context_menu();
|
||||
bool add_app_to_desktop();
|
||||
|
||||
+private:
|
||||
+ void on_add_favorite_app();
|
||||
+ void on_del_favorite_app();
|
||||
+
|
||||
private:
|
||||
KiranOpacityMenu context_menu;
|
||||
Gtk::MenuItem *items;
|
||||
diff --git a/src/menu/menu-applet-window.cpp b/src/menu/menu-applet-window.cpp
|
||||
index 941c2b8..eea61c9 100644
|
||||
--- a/src/menu/menu-applet-window.cpp
|
||||
+++ b/src/menu/menu-applet-window.cpp
|
||||
@@ -63,8 +63,7 @@ MenuAppletWindow::MenuAppletWindow(Gtk::WindowType window_type) : Glib::ObjectBa
|
||||
/* 监控工作区域大小变化 */
|
||||
auto screen = get_screen();
|
||||
monitor = new WorkareaMonitor(screen);
|
||||
- monitor->signal_size_changed().connect(
|
||||
- sigc::mem_fun(*this, &MenuAppletWindow::on_workarea_size_changed));
|
||||
+ monitor->signal_size_changed().connect(sigc::mem_fun(*this, &MenuAppletWindow::on_workarea_size_changed));
|
||||
|
||||
//加载当前用户信息
|
||||
set_display_mode(profile.get_display_mode());
|
||||
diff --git a/src/menu/menu-apps-container.cpp b/src/menu/menu-apps-container.cpp
|
||||
index 4930e46..b849397 100644
|
||||
--- a/src/menu/menu-apps-container.cpp
|
||||
+++ b/src/menu/menu-apps-container.cpp
|
||||
@@ -32,7 +32,8 @@ MenuAppsContainer::MenuAppsContainer(MenuAppsContainer::AppIconMode mode_,
|
||||
apps_box.get_style_context()->add_class("menu-apps-box");
|
||||
|
||||
category_box.signal_clicked().connect_notify(
|
||||
- [this]() -> void {
|
||||
+ [this]() -> void
|
||||
+ {
|
||||
signal_category_clicked().emit(category_box.get_category_name());
|
||||
});
|
||||
|
||||
@@ -142,11 +143,6 @@ bool MenuAppsContainer::get_category_clickable() const
|
||||
return category_box.get_clickable();
|
||||
}
|
||||
|
||||
-sigc::signal<void> MenuAppsContainer::signal_app_launched()
|
||||
-{
|
||||
- return m_signal_app_launched;
|
||||
-}
|
||||
-
|
||||
sigc::signal<void, const Glib::ustring &> MenuAppsContainer::signal_category_clicked()
|
||||
{
|
||||
return m_signal_category_clicked;
|
||||
@@ -157,10 +153,6 @@ MenuAppItem *MenuAppsContainer::create_app_item(std::shared_ptr<Kiran::App> app,
|
||||
auto item = new MenuAppItem(app);
|
||||
|
||||
item->set_orientation(orient);
|
||||
- item->signal_launched().connect(
|
||||
- [this]() -> void {
|
||||
- signal_app_launched().emit();
|
||||
- });
|
||||
|
||||
return item;
|
||||
}
|
||||
diff --git a/src/menu/menu-apps-container.h b/src/menu/menu-apps-container.h
|
||||
index d5bfcfe..85148e3 100644
|
||||
--- a/src/menu/menu-apps-container.h
|
||||
+++ b/src/menu/menu-apps-container.h
|
||||
@@ -83,13 +83,6 @@ public:
|
||||
*/
|
||||
virtual bool load_applications(const Kiran::AppVec &apps);
|
||||
|
||||
- /**
|
||||
- * @brief signal_app_launched 信号,容器内的应用按钮启动时触发
|
||||
- *
|
||||
- * @return 返回应用启动信号
|
||||
- */
|
||||
- sigc::signal<void> signal_app_launched();
|
||||
-
|
||||
/**
|
||||
* @brief siganl_category_clicked 信号,容器内的应用分类标签点击后触发
|
||||
*/
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
From dc5e56b311f49532213a6a6445dc77e1f0cc4661 Mon Sep 17 00:00:00 2001
|
||||
From: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
Date: Tue, 9 Aug 2022 10:49:36 +0800
|
||||
Subject: [PATCH 2/2] fix(coredump): Fix the coredump problem caused by
|
||||
nullpointer to UserIcon.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
- 修复由于访问用户图标对象为空导致的崩溃问题
|
||||
|
||||
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
|
||||
---
|
||||
src/menu/menu-avatar-widget.cpp | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/menu/menu-avatar-widget.cpp b/src/menu/menu-avatar-widget.cpp
|
||||
index 194a55e..74f8c49 100644
|
||||
--- a/src/menu/menu-avatar-widget.cpp
|
||||
+++ b/src/menu/menu-avatar-widget.cpp
|
||||
@@ -82,7 +82,8 @@ bool MenuAvatarWidget::on_draw(const ::Cairo::RefPtr<Cairo::Context> &cr)
|
||||
auto radius = image_size / 2.0;
|
||||
try
|
||||
{
|
||||
- pixbuf = Gdk::Pixbuf::create_from_file(user_info.get_iconfile(),
|
||||
+ auto icon_file = user_info.get_iconfile();
|
||||
+ pixbuf = Gdk::Pixbuf::create_from_file(icon_file ? icon_file : std::string(),
|
||||
allocation.get_width() * scale,
|
||||
allocation.get_height() * scale);
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: kiran-menu
|
||||
Version: 2.3.0
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: Applets for mate panel from Kiran Desktop
|
||||
|
||||
License: Mulan PSL v2
|
||||
@ -10,6 +10,8 @@ Patch1000: 0001-fix-menu-Fix-the-switch-user-error-by-xdmcp-logging.patch
|
||||
Patch1001: 0001-fix-menu-Fix-the-problem-that-some-apps-are-show-rep.patch
|
||||
Patch1002: 0002-fix-tray-Fix-the-problem-that-fcitx-doesn-t-show-in-.patch
|
||||
Patch1003: 0001-fix-menu-fix-the-grab-problem-when-popup-menu-on-sea.patch
|
||||
Patch1004: 0001-fix-connect-Fix-some-possible-crash-problems-caused-.patch
|
||||
Patch1005: 0002-fix-coredump-Fix-the-coredump-problem-caused-by-null.patch
|
||||
|
||||
|
||||
BuildRequires: cmake > 3.0
|
||||
@ -89,6 +91,10 @@ gtk-update-icon-cache -f /usr/share/icons/hicolor/
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Aug 09 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.3.0-6
|
||||
- KYOS-B: Fix the coredump problem caused by nullpointer to UserIcon.
|
||||
- KYOS-B: Fix some possible crash problems caused by sigc::slot.
|
||||
|
||||
* Tue Aug 02 2022 tangjie02 <tangjie02@kylinsec.com.cn> - 2.3.0-5
|
||||
- KYOS-B: fix the grab problem when popup menu on search entry or drag menu app icon.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user