Commit ba48dbd
committed
fix: Listen for ui_database_closed to ensure safe cleanup
src/plugin.cpp (modified):
- StructorPlugin now inherits from event_listener_t to intercept UI notifications.
- Added on_event implementation to trigger cleanup specifically on the ui_database_closed event.
- Extracted shutdown logic (unregistering IDC functions, saving config) from the destructor into a new idempotent cleanup() method.
- Added hook_event_listener/unhook_event_listener calls for HT_UI in the constructor and destructor.
- Introduced a cleaned_up_ flag to prevent double-execution of the cleanup logic.
Impact:
- Ensures plugin resources and configuration are saved immediately when the database closes, rather than waiting for the plugin destructor.
- Prevents potential crashes caused by accessing Qt widgets or internal state after the UI context has been destroyed.1 parent a30cb60 commit ba48dbd
1 file changed
+28
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
| 122 | + | |
121 | 123 | | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
| |||
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| |||
139 | 145 | | |
140 | 146 | | |
141 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
142 | 156 | | |
143 | 157 | | |
144 | 158 | | |
| |||
149 | 163 | | |
150 | 164 | | |
151 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
152 | 178 | | |
| 179 | + | |
153 | 180 | | |
154 | 181 | | |
155 | 182 | | |
| |||
0 commit comments