-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/SDL memory leaks #41
base: develop
Are you sure you want to change the base?
Changes from 5 commits
ae8d848
5a07552
5f9174c
be4a738
ed572e6
dff6e3e
e62a8eb
b985f83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,66 @@ using ::testing::Return; | |
using ::testing::ReturnPointee; | ||
using ::testing::ReturnRef; | ||
|
||
ResumptionDataTest::~ResumptionDataTest() { | ||
for (auto& submenu : test_submenu_map) { | ||
delete submenu.second; | ||
} | ||
|
||
test_submenu_map.clear(); | ||
|
||
for (auto& command : test_commands_map) { | ||
delete command.second; | ||
} | ||
|
||
test_commands_map.clear(); | ||
|
||
for (auto& choiceset : test_choiceset_map) { | ||
delete choiceset.second; | ||
} | ||
|
||
test_choiceset_map.clear(); | ||
|
||
if (help_prompt_) { | ||
delete help_prompt_; | ||
help_prompt_ = nullptr; | ||
} | ||
|
||
if (timeout_prompt_) { | ||
delete timeout_prompt_; | ||
timeout_prompt_ = nullptr; | ||
} | ||
|
||
if (vr_help_) { | ||
delete vr_help_; | ||
vr_help_ = nullptr; | ||
} | ||
|
||
if (vr_help_title_) { | ||
delete vr_help_title_; | ||
vr_help_title_ = nullptr; | ||
} | ||
|
||
if (vr_synonyms_) { | ||
delete vr_synonyms_; | ||
vr_synonyms_ = nullptr; | ||
} | ||
|
||
if (keyboard_props_) { | ||
delete keyboard_props_; | ||
keyboard_props_ = nullptr; | ||
} | ||
|
||
if (menu_title_) { | ||
delete menu_title_; | ||
menu_title_ = nullptr; | ||
} | ||
|
||
if (menu_icon_) { | ||
delete menu_icon_; | ||
menu_icon_ = nullptr; | ||
} | ||
} | ||
|
||
void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { | ||
EXPECT_EQ(policy_app_id_, resume_app_list[am::strings::app_id].asString()); | ||
EXPECT_EQ(grammar_id_, resume_app_list[am::strings::grammar_id].asUInt()); | ||
|
@@ -442,7 +502,17 @@ void ResumptionDataTest::SetMenuTitleAndIcon() { | |
|
||
sm::SmartObject sm_title; | ||
sm_title = "test title"; | ||
|
||
if (menu_title_) { | ||
delete menu_title_; | ||
} | ||
|
||
menu_title_ = new sm::SmartObject(sm_title); | ||
|
||
if (menu_icon_) { | ||
delete menu_icon_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SNiukalov Smart pointers for all such items? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AByzhynar |
||
} | ||
|
||
menu_icon_ = new sm::SmartObject(sm_icon); | ||
} | ||
|
||
|
@@ -456,14 +526,24 @@ void ResumptionDataTest::SetHelpAndTimeoutPrompt() { | |
help_prompt[i][am::strings::text] = "help prompt name" + std::string(numb); | ||
help_prompt[i][am::strings::type] = SpeechCapabilities::PRE_RECORDED; | ||
} | ||
|
||
if (help_prompt_) { | ||
delete help_prompt_; | ||
} | ||
|
||
help_prompt_ = new sm::SmartObject(help_prompt); | ||
|
||
for (uint i = 0; i < tts_chunks_count; ++i) { | ||
char numb[12]; | ||
std::snprintf(numb, 12, "%d", i); | ||
timeout_prompt[i][am::strings::text] = "timeout test" + std::string(numb); | ||
timeout_prompt[i][am::strings::type] = SpeechCapabilities::SC_TEXT; | ||
} | ||
|
||
if (timeout_prompt_) { | ||
delete timeout_prompt_; | ||
} | ||
|
||
timeout_prompt_ = new sm::SmartObject(timeout_prompt); | ||
} | ||
|
||
|
@@ -479,7 +559,16 @@ void ResumptionDataTest::SetVRHelpTitle() { | |
vr_help[i][am::strings::position] = i; | ||
} | ||
|
||
if (vr_help_) { | ||
delete vr_help_; | ||
} | ||
|
||
vr_help_ = new sm::SmartObject(vr_help); | ||
|
||
if (vr_help_title_) { | ||
delete vr_help_title_; | ||
} | ||
|
||
vr_help_title_ = new sm::SmartObject(vr_help_title); | ||
} | ||
|
||
|
@@ -591,6 +680,11 @@ void ResumptionDataTest::SetKeyboardProperties() { | |
keyboard[am::strings::auto_complete_text] = "complete"; | ||
keyboard[am::strings::limited_character_list][0] = "y"; | ||
keyboard[am::strings::limited_character_list][1] = "n"; | ||
|
||
if (keyboard_props_) { | ||
delete keyboard_props_; | ||
} | ||
|
||
keyboard_props_ = new sm::SmartObject(keyboard); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,8 @@ class AsyncRunner { | |
public: | ||
AsyncRunnerDelegate(); | ||
|
||
~AsyncRunnerDelegate(); | ||
|
||
/** | ||
* @brief threadMain runs delegates queue handling. | ||
*/ | ||
|
@@ -111,6 +113,11 @@ class AsyncRunner { | |
*/ | ||
void waitForDelegate(); | ||
|
||
/** | ||
* @bref clearDelegateQueue delete leftover delegates in the queue | ||
*/ | ||
void clearDelegateQueue(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SNiukalov Wrong naming(Coding style). The function name should start with a capital letter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AByzhynar |
||
|
||
std::queue<threads::ThreadDelegate*> delegates_queue_; | ||
sync_primitives::ConditionalVariable delegate_notifier_; | ||
sync_primitives::Lock delegates_queue_lock_; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SNiukalov why do we dlete only second item? Don't we clear the entire map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AByzhynar
Fixed in:be4a738