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
This commit is contained in:
Dominik Riebeling 2007-08-30 16:55:04 +00:00
parent 189de39258
commit 50af4dc089

View file

@ -517,13 +517,16 @@ void Config::autodetect()
if(detector.detect()) //let it detect if(detector.detect()) //let it detect
{ {
QString devicename = detector.getDevice(); QString devicename = detector.getDevice();
//deexpand the platform
ui.treeDevices->selectedItems().at(0)->parent()->setExpanded(false); if(ui.treeDevices->selectedItems().size() > 0) {
//deselect the selected item // deexpand the platform
ui.treeDevices->selectedItems().at(0)->setSelected(false); ui.treeDevices->selectedItems().at(0)->parent()->setExpanded(false);
//deselect the selected item
ui.treeDevices->selectedItems().at(0)->setSelected(false);
}
// find the new item // find the new item
//enumerate al plattform items // enumerate all platform items
QList<QTreeWidgetItem*> itmList= ui.treeDevices->findItems("*",Qt::MatchWildcard); QList<QTreeWidgetItem*> itmList= ui.treeDevices->findItems("*",Qt::MatchWildcard);
for(int i=0; i< itmList.size();i++) 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(); 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)->child(j)->setSelected(true); //select the item
itmList.at(i)->setExpanded(true); //expand the platform item itmList.at(i)->setExpanded(true); //expand the platform item