From 331b3e22a19b3ec85103f075e4f00d82f88f6558 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 11 May 2016 08:57:34 -0400 Subject: Fix a desktop crash which only seems to happen if you have an existing, but invalid application listed in the users favorites when the start button is clicked. --- .../panel-plugins/systemstart/ItemWidget.cpp | 10 +++---- .../panel-plugins/systemstart/StartMenu.cpp | 31 ++++++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src-qt5/core/lumina-desktop/panel-plugins') diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp index bdd13b18..a742384d 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp @@ -16,9 +16,10 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob bool inHome = type.endsWith("-home"); //internal code if(inHome){ type = type.remove("-home"); } if(itemPath.endsWith(".desktop") || type=="app"){ - bool ok = false; - XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok); - if(ok && LXDG::checkValidity(item) ){ + XDGDesktop item = LXDG::loadDesktopFile(itemPath, gooditem); + if(gooditem){ gooditem = LXDG::checkValidity(item); } + //qDebug() << "Good Item:" << gooditem << itemPath; + if(gooditem){ icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(32,32) ); iconPath = item.icon; text = item.name; @@ -27,7 +28,6 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob name->setToolTip(item.comment); setupActions(item); }else{ - gooditem = false; return; } }else if(type=="dir"){ @@ -253,4 +253,4 @@ void ItemWidget::actionClicked(QAction *act){ if(!linkPath.isEmpty()){ cmd = cmd.arg(linkPath); } else{ cmd = cmd.arg(icon->whatsThis()); } emit RunItem(cmd); -} \ No newline at end of file +} diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp index 9f172096..1d22632a 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp @@ -101,8 +101,8 @@ void StartMenu::UpdateAll(){ ui->stackedWidget->setCurrentWidget(ui->page_main); //need to ensure the settings page is not active ui->combo_locale->clear(); QString curr = LUtils::currentLocale(); - qDebug() << "Update Locales:" << locales; - qDebug() << "Current Locale:" << curr; + //qDebug() << "Update Locales:" << locales; + //qDebug() << "Current Locale:" << curr; for(int i=0; icombo_locale->addItem(loc.nativeLanguageName() +" ("+locales[i]+")", locales[i]); //Make the display text prettier later @@ -121,14 +121,18 @@ void StartMenu::UpdateAll(){ } void StartMenu::UpdateMenu(bool forceall){ + //qDebug() << "Update Menu" << forceall; if(forceall){ UpdateAll(); } //Quick update routine before the menu is made visible + //qDebug() << "update favs"; UpdateFavs(); + //qDebug() << "check page"; if(ui->stackedWidget->currentWidget() != ui->page_main){ ui->stackedWidget->setCurrentWidget(ui->page_main); //just show the main page }else{ on_stackedWidget_currentChanged(0); //refresh/update the main page every time } + //qDebug() << "done"; } void StartMenu::ReLoadQuickLaunch(){ @@ -312,6 +316,7 @@ void StartMenu::UpdateFavs(){ else{ tmp = rest; } //everything left over if(type==1){ //Need to run a special routine for sorting the apps (already in the widget) + //qDebug() << "Sort App Widgets..."; // Since each app actually might have a different name listed within the file QLayout *lay = ui->scroll_favs->widget()->layout(); QStringList items; @@ -320,7 +325,7 @@ void StartMenu::UpdateFavs(){ } items.sort(); - //qDebug() << " - Sorted Items:" << items; + // qDebug() << " - Sorted Items:" << items; for(int i=0; iscroll_favs->widget(), tmp[i].section("::::",2,50), tmp[i].section("::::",1,1) ); - if(!it->gooditem){ continue; } //invalid for some reason + if( !QFile::exists(tmp[i].section("::::",2,-1)) ){ continue; } //invalid favorite - skip it + ItemWidget *it = 0; + if( tmp[i].section("::::",2,-1).endsWith(".desktop")){ + bool ok = false; + XDGDesktop item = LXDG::loadDesktopFile(tmp[i].section("::::",2,-1), ok); + if(ok){ ok = LXDG::checkValidity(item); } + if(ok){ it = new ItemWidget(ui->scroll_favs->widget(), item); } + }else{ + it = new ItemWidget(ui->scroll_favs->widget(), tmp[i].section("::::",2,-1), tmp[i].section("::::",1,1) ); + } + if(it==0){ continue; } + if(!it->gooditem){ it->deleteLater(); continue; } //invalid for some reason ui->scroll_favs->widget()->layout()->addWidget(it); connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) ); connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) ); connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) ); } - QApplication::processEvents(); - } + //QApplication::processEvents(); + } //end loop over types + //qDebug() << "End updateFavs"; } // Page update routines -- cgit