diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index d8ec72fd0..3cfaacfdf 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -2603,24 +2603,27 @@ bool p3ConnectMgr::setLocalAddress(std::string id, struct sockaddr_in addr) if (id == AuthSSL::getAuthSSL()->OwnId()) { + if (ownState.currentlocaladdr.sin_addr.s_addr != addr.sin_addr.s_addr || + ownState.currentlocaladdr.sin_port != addr.sin_port) { { - RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ - ownState.currentlocaladdr = addr; - //avoid 0 for port and address - if (ownState.currentlocaladdr.sin_addr.s_addr == 0) { - ownState.currentlocaladdr.sin_addr.s_addr = 1; - } - if (addr.sin_port == 0) { - ownState.currentlocaladdr.sin_port = 1; - } + RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ + ownState.currentlocaladdr = addr; + //avoid 0 for port and address + if (ownState.currentlocaladdr.sin_addr.s_addr == 0) { + ownState.currentlocaladdr.sin_addr.s_addr = 1; + } + if (addr.sin_port == 0) { + ownState.currentlocaladdr.sin_port = 1; + } } IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ if ((ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_EXT || (ownState.netMode & RS_NET_MODE_ACTUAL) == RS_NET_MODE_UDP) { netReset(); } - return true; - } + } + return true; + } RsStackMutex stack(connMtx); /****** STACK LOCK MUTEX *******/ /* check if it is a friend */ diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 3c27a402c..a14156a51 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -84,7 +84,7 @@ RSettingsWin::closeEvent (QCloseEvent * event) if (update_local) { if (_instance->stackedWidget->currentIndex() == Directories) { - ConfigPage *Page = (ConfigPage*) _instance->stackedWidget->currentWidget(); + ConfigPage *Page = dynamic_cast (_instance->stackedWidget->currentWidget()); if (Page) { Page->load(); } @@ -110,6 +110,8 @@ RSettingsWin::initStackedWidget() stackedWidget->addWidget(new SoundPage() ); #endif + loadSettings(); /* load saved settings */ + setNewPage(General); } @@ -163,7 +165,6 @@ RSettingsWin::setNewPage(int page) } pageName->setText(text); - loadSettings(); /* load saved settings */ stackedWidget->setCurrentIndex(page); listWidget->setCurrentRow(page); } @@ -171,12 +172,14 @@ RSettingsWin::setNewPage(int page) void RSettingsWin::loadSettings() { - /* Call each config page's load() method to load its data */ - int i, count = stackedWidget->count(); - for (i = 0; i < count; i++) { - ConfigPage *page = (ConfigPage *) stackedWidget->widget(i); - page->load(); - } + /* Call each config page's load() method to load its data */ + int i, count = stackedWidget->count(); + for (i = 0; i < count; i++) { + ConfigPage *page = dynamic_cast (stackedWidget->widget(i)); + if (page) { + page->load(); + } + } } /** Saves changes made to settings. */ @@ -191,7 +194,7 @@ RSettingsWin::saveChanges() { ConfigPage *page = dynamic_cast(stackedWidget->widget(i)); - if(!page->save(errmsg)) + if(page && !page->save(errmsg)) { /* Display the offending page */ stackedWidget->setCurrentWidget(page);