diff --git a/mythplugins/mytharchive/mytharchivehelper/main.cpp b/mythplugins/mytharchive/mytharchivehelper/main.cpp
index 92b041f..ea33aef 100644
a
|
b
|
extern "C" { |
75 | 75 | // mytharchive headers |
76 | 76 | #include "../mytharchive/archiveutil.h" |
77 | 77 | |
| 78 | namespace |
| 79 | { |
| 80 | void cleanup() |
| 81 | { |
| 82 | delete gContext; |
| 83 | gContext = NULL; |
| 84 | } |
| 85 | |
| 86 | class CleanupGuard |
| 87 | { |
| 88 | public: |
| 89 | typedef void (*CleanupFunc)(); |
| 90 | |
| 91 | public: |
| 92 | CleanupGuard(CleanupFunc cleanFunction) : |
| 93 | m_cleanFunction(cleanFunction) {} |
| 94 | |
| 95 | ~CleanupGuard() |
| 96 | { |
| 97 | m_cleanFunction(); |
| 98 | } |
| 99 | |
| 100 | private: |
| 101 | CleanupFunc m_cleanFunction; |
| 102 | }; |
| 103 | } |
| 104 | |
78 | 105 | class NativeArchive |
79 | 106 | { |
80 | 107 | public: |
… |
… |
int main(int argc, char **argv) |
2625 | 2652 | // Don't listen to console input |
2626 | 2653 | close(0); |
2627 | 2654 | |
| 2655 | CleanupGuard callCleanup(cleanup); |
2628 | 2656 | gContext = new MythContext(MYTH_BINARY_VERSION); |
2629 | 2657 | if (!gContext->Init(false)) |
2630 | 2658 | { |
2631 | 2659 | LOG(VB_GENERAL, LOG_ERR, "Failed to init MythContext, exiting."); |
2632 | | delete gContext; |
2633 | 2660 | return GENERIC_EXIT_NO_MYTHCONTEXT; |
2634 | 2661 | } |
2635 | 2662 | |