Memory leak in RefreshMapper, fixes #5323
This commit is contained in:
parent
351f8f4e12
commit
159e1784f4
@ -19,12 +19,13 @@
|
||||
*/
|
||||
|
||||
#include "eventmapper.h"
|
||||
#include "multilangmgr.h"
|
||||
|
||||
|
||||
ProcEventMapper::ProcEventMapper()
|
||||
{
|
||||
for (int event = 0; event < rtengine::NUMOFEVENTS; ++event) {
|
||||
history_msgs_[event] = "HISTORY_MSG_" + std::to_string(event + 1);
|
||||
history_msgs_[event] = M("HISTORY_MSG_" + std::to_string(event + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,16 +39,22 @@ ProcEventMapper *ProcEventMapper::getInstance()
|
||||
|
||||
rtengine::ProcEvent ProcEventMapper::newEvent(int action, const std::string &history_msg)
|
||||
{
|
||||
std::string eventkey = std::to_string(action) + history_msg;
|
||||
const auto ret = events_.find(eventkey);
|
||||
if (ret == events_.end()) {
|
||||
rtengine::ProcEvent event = rtengine::RefreshMapper::getInstance()->newEvent();
|
||||
rtengine::RefreshMapper::getInstance()->mapEvent(event, action);
|
||||
|
||||
events_.emplace(std::move(eventkey), event);
|
||||
if (history_msg.empty()) {
|
||||
history_msgs_[event] = "HISTORY_MSG_" + std::to_string(event + 1);
|
||||
history_msgs_[event] = M("HISTORY_MSG_" + std::to_string(event + 1));
|
||||
} else {
|
||||
history_msgs_[event] = history_msg;
|
||||
history_msgs_[event] = M(history_msg);
|
||||
}
|
||||
|
||||
return event;
|
||||
} else {
|
||||
return ret->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include "../rtengine/refreshmap.h"
|
||||
|
||||
@ -34,4 +35,5 @@ private:
|
||||
ProcEventMapper();
|
||||
|
||||
std::unordered_map<int, std::string> history_msgs_;
|
||||
std::map<std::string, rtengine::ProcEvent> events_;
|
||||
};
|
||||
|
@ -233,7 +233,6 @@ void History::procParamsChanged(
|
||||
}
|
||||
|
||||
// construct formatted list content
|
||||
Glib::ustring text = M(ProcEventMapper::getInstance()->getHistoryMsg(ev));
|
||||
|
||||
Glib::RefPtr<Gtk::TreeSelection> selection = hTreeView->get_selection();
|
||||
Gtk::TreeModel::iterator iter = selection->get_selected();
|
||||
@ -248,7 +247,7 @@ void History::procParamsChanged(
|
||||
}
|
||||
|
||||
// lookup the last remaining item in the list
|
||||
int size = historyModel->children().size ();
|
||||
const int size = historyModel->children().size();
|
||||
Gtk::TreeModel::Row row;
|
||||
|
||||
if (size > 0) {
|
||||
@ -258,7 +257,7 @@ void History::procParamsChanged(
|
||||
// if there is no last item or its chev!=ev, create a new one
|
||||
if (size == 0 || !row || row[historyColumns.chev] != ev || ev == EvProfileChanged) {
|
||||
Gtk::TreeModel::Row newrow = *(historyModel->append());
|
||||
newrow[historyColumns.text] = text;
|
||||
newrow[historyColumns.text] = ProcEventMapper::getInstance()->getHistoryMsg(ev);
|
||||
newrow[historyColumns.value] = g_markup_escape_text(descr.c_str(), -1);
|
||||
newrow[historyColumns.chev] = ev;
|
||||
newrow[historyColumns.params] = *params;
|
||||
@ -273,12 +272,8 @@ void History::procParamsChanged(
|
||||
} else if (blistener && size == 0 && !blistenerLock) {
|
||||
blistener->historyBeforeLineChanged(newrow[historyColumns.params]);
|
||||
}
|
||||
}
|
||||
// else just update it
|
||||
else {
|
||||
row[historyColumns.text] = text;
|
||||
} else { // else just update it
|
||||
row[historyColumns.value] = g_markup_escape_text(descr.c_str(), -1);
|
||||
row[historyColumns.chev] = ev;
|
||||
row[historyColumns.params] = *params;
|
||||
row[historyColumns.paramsEdited] = paramsEdited ? *paramsEdited : defParamsEdited;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user