Fixed floating label context dtors sometimes getting stuck in an infinite loop

This fixes #2154. For some reason, after opening help from the File menu and then quitting to desktop,
the number of labels recorded in the label map and context set weren't equal. I'm not exactly sure
why, since the code seems to indicate they should be, and the loop doesn't seem to be hit when only
invoking help with the hotkey (F1).

This just removes the predication of a label being present in the label map for removal from the context
set. I also removed two useless, unused variables that I'm surprised no one's complained about.
This commit is contained in:
Charles Dang 2017-11-03 07:48:49 +11:00
parent a82eb4452f
commit ba3c6ec3da

View file

@ -227,12 +227,12 @@ void remove_floating_label(int handle)
{
const label_map::iterator i = labels.find(handle);
if(i != labels.end()) {
if(label_contexts.empty() == false) {
label_contexts.top().erase(i->first);
}
labels.erase(i);
}
if(!label_contexts.empty()) {
label_contexts.top().erase(handle);
}
}
void show_floating_label(int handle, bool value)
@ -257,24 +257,20 @@ SDL_Rect get_floating_label_rect(int handle)
floating_label_context::floating_label_context()
{
const surface screen = nullptr;
label_contexts.emplace();
}
floating_label_context::~floating_label_context()
{
const std::set<int>& context = label_contexts.top();
while (!context.empty())
{
while(!context.empty()) {
// Remove_floating_label removes the passed label from the context.
// This loop removes a different label in every iteration.
remove_floating_label(*context.begin());
}
label_contexts.pop();
const surface screen = nullptr;
}
void draw_floating_labels(surface screen)