OpenCPN Partial API docs
Loading...
Searching...
No Matches
safe_mode_gui.cpp
1#include <cstdio>
2#include <string>
3#include <fstream>
4
5#include <wx/dialog.h>
6#include <wx/filename.h>
7#include <wx/sizer.h>
8
9#include "model/cmdline.h"
10#include "gui_lib.h"
11#include "model/ocpn_utils.h"
12
13#include "model/safe_mode.h"
14
15namespace safe_mode {
16
17static const int TIMEOUT_SECONDS = 15;
18
19static const char* LAST_RUN_ERROR_MSG =
20 _("<p>The last opencpn run seems to have failed. Do you want to run\n"
21 "in safe mode without plugins and other possibly problematic\n"
22 "features?\n</p><br/></br><p>You may consider visiting the <a "
23 "href=\"https://github.com/OpenCPN/OpenCPN/wiki/"
24 "OpenCPN-5.10-known-issues\">list of known issues</a>.</p>");
25
31 std::string path = check_file_path();
32 if (!ocpn::exists(path)) {
33 std::ofstream dest(path, std::ios::binary);
34 dest << "Internal opencpn use" << std::endl;
35 dest.close();
36 return;
37 }
38 long style = wxYES | wxNO | wxNO_DEFAULT | wxICON_QUESTION;
39 auto dlg = new OCPN_TimedHTMLMessageDialog(0, LAST_RUN_ERROR_MSG,
40 _("Safe restart"), TIMEOUT_SECONDS,
41 style, false, wxDefaultPosition);
42 int reply = dlg->ShowModal();
43 safe_mode = reply == wxID_YES;
44 dlg->Destroy();
45}
46
47} // namespace safe_mode
Global variables reflecting command line options and arguments.
General purpose GUI support.
Safe mode handling.
Definition safe_mode.cpp:14
void check_last_start()
Check if the last start failed, possibly invoke user dialog and set safe mode state.