fixed: in Finder: we should set model_data to nullptr after fetching an object
model_data points often to a local object (on the stack) so it would be incorrect to use it in the future git-svn-id: svn://ttmath.org/publicrep/morm/trunk@1131 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
346fe193f3
commit
011d8f96e8
11
src/finder.h
11
src/finder.h
|
@ -475,6 +475,7 @@ public:
|
|||
// if yes then make sure to call db_connector->clear_last_query_result();
|
||||
}
|
||||
|
||||
result.model_data = nullptr;
|
||||
db_connector->clear_last_query_result();
|
||||
}
|
||||
}
|
||||
|
@ -519,6 +520,8 @@ public:
|
|||
result.emplace_back(); // it returns a reference from c++17
|
||||
ModelClass & added_model = result.back();
|
||||
|
||||
try
|
||||
{
|
||||
added_model.set_connector(model_connector);
|
||||
added_model.clear();
|
||||
added_model.set_save_mode(Model::DO_UPDATE_ON_SAVE); // IMPROVE ME check if there is a primary key
|
||||
|
@ -526,7 +529,15 @@ public:
|
|||
added_model.before_select();
|
||||
added_model.map_values_from_query();
|
||||
added_model.after_select();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
res = false;
|
||||
// throw or something?
|
||||
// make sure to call db_connector->clear_last_query_result()
|
||||
}
|
||||
|
||||
added_model.model_data = nullptr;
|
||||
db_connector->advance_current_row();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue