diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-11-01 08:58:34 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-11-01 08:58:34 +0100 |
| commit | 9b8664daf17dac9efb1f4add9d00c562e4ddbf40 (patch) | |
| tree | 6c3396be134996ee3ce75b0ff9a2eca09452104d /src/administration_writer.cpp | |
| parent | 60488d722bf29f3ff0ce3e08b90f30523a8d7b6d (diff) | |
fix tests
Diffstat (limited to 'src/administration_writer.cpp')
| -rw-r--r-- | src/administration_writer.cpp | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/administration_writer.cpp b/src/administration_writer.cpp index c45ec6e..c699a0a 100644 --- a/src/administration_writer.cpp +++ b/src/administration_writer.cpp @@ -54,8 +54,12 @@ static void on_administration_data_changed() if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, 0); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_administration_data_deleted(char id[MAX_LEN_ID]) @@ -75,8 +79,12 @@ static void on_administration_data_deleted(char id[MAX_LEN_ID]) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)id_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_invoice_changed(invoice* inv) @@ -97,8 +105,12 @@ static void on_invoice_changed(invoice* inv) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)inv_copy2); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_contact_changed_changed(contact* cc) @@ -107,19 +119,23 @@ static void on_contact_changed_changed(contact* cc) contact* cc_copy = (contact*)memops::alloc(sizeof(contact)); memops::copy(cc_copy, cc, sizeof(contact)); - + auto* func = new auto([](void* arg) { contact* cc = (contact*)arg; administration_writer::save_contact_blocking(*cc); administration_writer::save_administration_info_blocking(); memops::unalloc(arg); - + _is_writing = false; if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)cc_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_taxrate_changed_changed(tax_rate* rate) @@ -139,8 +155,12 @@ static void on_taxrate_changed_changed(tax_rate* rate) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)rate_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_costcenter_changed_changed(cost_center* cc) @@ -159,8 +179,12 @@ static void on_costcenter_changed_changed(cost_center* cc) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; thrd_t thr; thrd_create(&thr, trampoline, (void*)cc_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } static void on_project_changed_changed(project* pp) @@ -180,8 +204,12 @@ static void on_project_changed_changed(project* pp) if (_write_completed_ev) _write_completed_ev(); }); - auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); delete f; return 0; }; - thrd_t thr; thrd_create(&thr, trampoline, (void*)pp_copy); + auto trampoline = [](void* arg) -> int { auto* f = static_cast<decltype(func)>(arg); (*f)(arg); return 0; }; + thrd_t thr; thrd_create(&thr, trampoline, (void*)pp_copy); + + #ifdef _TESTING_MODE_ + thrd_join(thr, 0); + #endif } bool administration_writer::create() |
