1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

OP-805 - fixed GCS Options page crash by removing configurations for which

an options page could not be created.
This commit is contained in:
filnet 2013-01-13 18:33:07 +01:00
parent a45578c250
commit ae9def7f11

View File

@ -239,8 +239,9 @@ void UAVGadgetInstanceManager::createOptionsPages()
m_pm->removeObject(m_optionsPages.takeLast()); m_pm->removeObject(m_optionsPages.takeLast());
} }
foreach (IUAVGadgetConfiguration *config, m_configurations) QMutableListIterator<IUAVGadgetConfiguration*> ite(m_configurations);
{ while (ite.hasNext()) {
IUAVGadgetConfiguration *config = ite.next();
IUAVGadgetFactory *f = factory(config->classId()); IUAVGadgetFactory *f = factory(config->classId());
IOptionsPage *p = f->createOptionsPage(config); IOptionsPage *p = f->createOptionsPage(config);
if (p) { if (p) {
@ -249,6 +250,14 @@ void UAVGadgetInstanceManager::createOptionsPages()
m_optionsPages.append(page); m_optionsPages.append(page);
m_pm->addObject(page); m_pm->addObject(page);
} }
else {
qWarning()
<< "UAVGadgetInstanceManager::createOptionsPages - failed to create options page for configuration "
+ config->classId() + ":" + config->name() + ", configuration will be removed.";
// The m_optionsPages list and m_configurations list must be in synch otherwise nasty issues happen later
// so if we fail to create an options page we must remove the associated configuration
ite.remove();
}
} }
} }