updated to throw exception (not assert) when item missing from listbox
This commit is contained in:
parent
b9bb1623a6
commit
c646d0371c
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "components.h"
|
#include "components.h"
|
||||||
|
|
||||||
#include <cassert>
|
//#include <cassert>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "metrics.h"
|
#include "metrics.h"
|
||||||
|
@ -410,7 +410,10 @@ void GraphicListBox::setItems(const vector<string> &items, const vector<string>
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicListBox::setSelectedItemIndex(int index, bool errorOnMissing){
|
void GraphicListBox::setSelectedItemIndex(int index, bool errorOnMissing){
|
||||||
if(errorOnMissing == true) assert(index>=0 && index<items.size());
|
//if(errorOnMissing == true) assert(index>=0 && index<items.size());
|
||||||
|
if(errorOnMissing == true && (index < 0 || index >= items.size())) {
|
||||||
|
throw megaglest_runtime_error("Index not found on list box: " + intToStr(index) + " size: " + intToStr(items.size()));
|
||||||
|
}
|
||||||
selectedItemIndex= index;
|
selectedItemIndex= index;
|
||||||
setText(getSelectedItem());
|
setText(getSelectedItem());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue