From 50af4dc0891385ad0ff7ae8ad9713f89b4014466 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Thu, 30 Aug 2007 16:55:04 +0000 Subject: When autodetecting, don't segfault if no item was previously selected and a device is found. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14533 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/configure.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'rbutil/rbutilqt/configure.cpp') diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 05d0352498..49fa82f993 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp @@ -517,13 +517,16 @@ void Config::autodetect() if(detector.detect()) //let it detect { QString devicename = detector.getDevice(); - //deexpand the platform - ui.treeDevices->selectedItems().at(0)->parent()->setExpanded(false); - //deselect the selected item - ui.treeDevices->selectedItems().at(0)->setSelected(false); + + if(ui.treeDevices->selectedItems().size() > 0) { + // deexpand the platform + ui.treeDevices->selectedItems().at(0)->parent()->setExpanded(false); + //deselect the selected item + ui.treeDevices->selectedItems().at(0)->setSelected(false); + } // find the new item - //enumerate al plattform items + // enumerate all platform items QList itmList= ui.treeDevices->findItems("*",Qt::MatchWildcard); for(int i=0; i< itmList.size();i++) { @@ -532,7 +535,7 @@ void Config::autodetect() { QString data = itmList.at(i)->child(j)->data(0, Qt::UserRole).toString(); - if( devicename.contains(data)) //item found + if(devicename == data) // item found { itmList.at(i)->child(j)->setSelected(true); //select the item itmList.at(i)->setExpanded(true); //expand the platform item -- cgit v1.2.3