KiCad PCB EDA Suite
Loading...
Searching...
No Matches
access_fast_exit.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20
22
23#include <atomic>
24#include <cstdio>
25
26#include <kiplatform/app.h>
27#include <trace_helpers.h>
28#include <wx/log.h>
29
30#ifdef _WIN32
31#include <windows.h>
32#include <ole2.h>
33#endif
34
35
36namespace
37{
38// The flag lives in kicommon so the kiface that sets it and the app that reads it share one copy
39std::atomic<bool> g_accessWorkerAbandoned{ false };
40} // namespace
41
42
44{
45 g_accessWorkerAbandoned.store( true );
46 wxLogTrace( traceDatabase, wxT( "An Access engine worker was abandoned" ) );
47}
48
49
51{
52 wxLogTrace( traceDatabase, wxT( "Exit check, Access worker abandoned %d" ),
53 g_accessWorkerAbandoned.load() ? 1 : 0 );
54
55 if( !g_accessWorkerAbandoned.load() )
56 return;
57
58#ifdef _WIN32
59 // Hands clipboard data to the system now, since nothing runs OLE teardown afterwards
60 OleFlushClipboard();
61#endif
62
63 std::fflush( nullptr );
64
65 // Send pending thread records to stderr, as wxWidgets does during normal shutdown
66 delete wxLog::SetActiveTarget( new wxLogStderr );
67 wxLog::FlushActive();
68
70}
void MarkAccessWorkerAbandoned()
Records that a worker inside the Access engine was abandoned.
void ExitFastIfAccessWorkerAbandoned(int aExitCode)
Ends the process without the normal teardown when an Access engine worker was abandoned,...
const wxChar *const traceDatabase
Flag to enable database library tracing.
void TerminateWithCode(int aExitCode)
End the process at once with the given exit code, skipping static destruction, atexit handlers and li...
Definition unix/app.cpp:136
wxLogTrace helper definitions.