From d711e09b685e906f4a7e845f4148fdd1c43a988e Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 3 Nov 2018 20:24:24 +0100 Subject: [PATCH] fixed bug causing IdChooser to reset the current id --- retroshare-gui/src/gui/gxs/GxsIdChooser.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index e72da2c81..77d2b3621 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -127,10 +127,13 @@ void GxsIdChooser::setDefaultId(const RsGxsId &defId) static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/) { GxsIdChooser *chooser = dynamic_cast(object); - if (!chooser) { + + if (!chooser) return; - } - + + int current_index = chooser->currentIndex(); + + QString current_id = (current_index >= 0)? chooser->itemData(current_index).toString() : "" ; // this prevents the objects that depend on what's in the combo-box to activate and // perform any change.Only user-changes should cause this. @@ -186,6 +189,16 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail chooser->model()->sort(0); + // now restore the current item. Problem is, we cannot use the ID position because it may have changed. + + if(!current_id.isNull()) + for(int indx=0;indxcount();++indx) + if(chooser->itemData(indx).toString() == current_id) + { + chooser->setCurrentIndex(indx); + break; + } + chooser->blockSignals(false) ; }