diff -Nru hud-14.10+15.10.20150820.1/debian/changelog hud-14.10+15.10.20151012/debian/changelog --- hud-14.10+15.10.20150820.1/debian/changelog 2015-10-12 14:57:31.000000000 +0000 +++ hud-14.10+15.10.20151012/debian/changelog 2015-10-12 14:57:32.000000000 +0000 @@ -1,3 +1,10 @@ +hud (14.10+15.10.20151012-0ubuntu1) wily; urgency=medium + + [ Andrea Azzarone ] + * Limit the number of menus exported to slow down memory leaks. + + -- Marco Trevisan (TreviƱo) Mon, 12 Oct 2015 14:37:24 +0000 + hud (14.10+15.10.20150820.1-0ubuntu1) wily; urgency=medium [ Pete Woods ] diff -Nru hud-14.10+15.10.20150820.1/libqtgmenu/internal/QtGMenuModel.cpp hud-14.10+15.10.20151012/libqtgmenu/internal/QtGMenuModel.cpp --- hud-14.10+15.10.20150820.1/libqtgmenu/internal/QtGMenuModel.cpp 2015-08-20 13:45:33.000000000 +0000 +++ hud-14.10+15.10.20151012/libqtgmenu/internal/QtGMenuModel.cpp 2015-10-12 14:37:22.000000000 +0000 @@ -27,6 +27,7 @@ using namespace qtgmenu; +static const int MAX_NUM_CHILDREN = 100; static const QRegularExpression SINGLE_UNDERSCORE("(? connection, const QString& bus_name, @@ -108,7 +109,7 @@ if( m_model ) { - m_size = g_menu_model_get_n_items( m_model.data() ); + m_size = std::min( MAX_NUM_CHILDREN, g_menu_model_get_n_items( m_model.data() ) ); } ChangeMenuItems( 0, m_size, 0 ); @@ -241,7 +242,7 @@ self->ChangeMenuItems( index, added, removed ); } -void QtGMenuModel::ChangeMenuItems( const int index, const int added, const int removed ) +void QtGMenuModel::ChangeMenuItems( const int index, int added, const int removed ) { const int n_items = g_menu_model_get_n_items( m_model.data() ); @@ -251,6 +252,12 @@ return; } + // Limit the menus exported to avoid memory wastage + if ( m_size + (added - removed) > MAX_NUM_CHILDREN ) + { + added = MAX_NUM_CHILDREN - (m_size - removed); + } + // process removed items first (see "items-changed" on the GMenuModel man page) if( removed > 0 ) { diff -Nru hud-14.10+15.10.20150820.1/libqtgmenu/internal/QtGMenuModel.h hud-14.10+15.10.20151012/libqtgmenu/internal/QtGMenuModel.h --- hud-14.10+15.10.20150820.1/libqtgmenu/internal/QtGMenuModel.h 2015-08-20 13:45:33.000000000 +0000 +++ hud-14.10+15.10.20151012/libqtgmenu/internal/QtGMenuModel.h 2015-10-12 14:37:22.000000000 +0000 @@ -82,7 +82,7 @@ static void MenuItemsChangedCallback( GMenuModel* model, gint index, gint removed, gint added, gpointer user_data ); - void ChangeMenuItems( const int index, const int added, const int removed ); + void ChangeMenuItems( const int index, int added, const int removed ); void ConnectCallback(); void DisconnectCallback();