From 11190682277e3ac14d976738576f20df04e63dc5 Mon Sep 17 00:00:00 2001 From: simonb Date: Sat, 22 Apr 2006 16:38:20 +0000 Subject: fix crash when toolbar disabled --- ChangeLog | 2 ++ src/Screen.cc | 7 ------- src/Slit.cc | 28 ++++++++++++++++++---------- src/Slit.hh | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2abe162..b5bf528 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.16: *06/04/22: + * Fix crash when toolbar disabled (Simon) + Slit.hh/cc Screen.cc * Couple of memory-based fixes from valgrind (Simon) Keys.cc Screen.cc MenuCreator.cc * Applied #1467926 and #1458069, minor other changes (Mathias) diff --git a/src/Screen.cc b/src/Screen.cc index d19d16f..a26c370 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1687,13 +1687,6 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { menu.insert(tabmenu_label, tab_menu); -#ifdef SLIT - if (slit() != 0) { - slit()->menu().setInternalMenu(); - menu.insert("Slit", &slit()->menu()); - } -#endif // SLIT - Configmenus::iterator it = m_configmenu_list.begin(); Configmenus::iterator it_end = m_configmenu_list.end(); for (; it != it_end; ++it) diff --git a/src/Slit.cc b/src/Slit.cc index e8cd72c..af3a0be 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -260,9 +260,6 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) m_slitmenu(scr.menuTheme(), scr.imageControl(), *scr.layerManager().getLayer(Layer::MENU)), - m_placement_menu(scr.menuTheme(), - scr.imageControl(), - *scr.layerManager().getLayer(Layer::MENU)), m_clientlist_menu(scr.menuTheme(), scr.imageControl(), *scr.layerManager().getLayer(Layer::MENU)), @@ -274,6 +271,7 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False)), //KDE v2.x m_layeritem(0), + m_slit_theme(new SlitTheme(scr.rootWindow().screenNumber())), m_strut(0), // resources @@ -301,6 +299,8 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) scr.resizeSig().attach(this); scr.reconfigureSig().attach(this); // if alpha changed (we disablethis signal when we get theme change sig) + scr.addConfigMenu(_FBTEXT(Slit, Slit, "Slit", "The Slit"), m_slitmenu); + frame.pixmap = None; // move the frame out of sight for a moment frame.window.move(-frame.window.width(), -frame.window.height()); @@ -1236,10 +1236,17 @@ void Slit::setupMenu() { FbTk::RefCount save_and_reconfigure(s_a_reconf_macro); FbTk::RefCount save_and_reconfigure_slit(s_a_reconf_slit_macro); + + // it'll be freed by the slitmenu (since not marked internal) + FbMenu *placement_menu = new FbMenu(m_screen.menuTheme(), + m_screen.imageControl(), + *m_screen.layerManager().getLayer(::Layer::MENU)); + + // setup base menu m_slitmenu.setLabel(_FBTEXT(Slit, Slit, "Slit", "The Slit")); m_slitmenu.insert(_FBTEXT(Menu, Placement, "Placement", "Title of Placement menu"), - &m_placement_menu); + placement_menu); m_slitmenu.insert(_FBTEXT(Menu, Layer, "Layer...", "Title of Layer menu"), m_layermenu.get()); @@ -1287,10 +1294,11 @@ void Slit::setupMenu() { m_slitmenu.updateMenu(); // setup sub menu - m_placement_menu.setLabel(_FBTEXT(Slit, Placement, "Slit Placement", "Slit Placement")); - m_placement_menu.setMinimumSublevels(3); + placement_menu->setLabel(_FBTEXT(Slit, Placement, "Slit Placement", "Slit Placement")); + placement_menu->setMinimumSublevels(3); m_layermenu->setInternalMenu(); m_clientlist_menu.setInternalMenu(); + m_slitmenu.setInternalMenu(); typedef pair PlacementP; typedef list Placements; @@ -1314,10 +1322,10 @@ void Slit::setupMenu() { Slit::Placement placement = place_menu.front().second; if (str == 0) { - m_placement_menu.insert(""); - m_placement_menu.setItemEnabled(i, false); + placement_menu->insert(""); + placement_menu->setItemEnabled(i, false); } else { - m_placement_menu.insert(new PlaceSlitMenuItem(str, *this, + placement_menu->insert(new PlaceSlitMenuItem(str, *this, placement, save_and_reconfigure)); @@ -1326,7 +1334,7 @@ void Slit::setupMenu() { } // finaly update sub menu - m_placement_menu.updateMenu(); + placement_menu->updateMenu(); } void Slit::moveToLayer(int layernum) { diff --git a/src/Slit.hh b/src/Slit.hh index 4e090e4..a30933a 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -147,7 +147,7 @@ private: FbTk::Timer m_timer; SlitClients m_client_list; - FbMenu m_slitmenu, m_placement_menu, m_clientlist_menu; + FbMenu m_slitmenu, m_clientlist_menu; std::auto_ptr m_layermenu; std::string m_filename; -- cgit v0.11.2