Fix Compile Warnings (#5963)

* Fix calls to depreciated wxPen constructor

* Fix use of wxTimerEvent

* Fix unrecognized character escape sequence

* Fix signed/unsigned mismatch

At least as much as possible without significantly altering parts of the application

* Clean unreferenced variables

* fix mistyped namespace selector

* Update deprecated calls

* Fix preprocessor statement

* Remove empty switch statements

* Change int vector used as bool to bool vector

* Remove empty control statements and related unused code

* Change multi character constant to string constant

* Fix discarded return value

json::parse was being called on the object, rather than statically like it should be. Also, the value was not being captured.

* Rename ICON_SIZE def used by MultiMachine

By having the definition in the header, it causes issues when other files define ICON_SIZE. By renaming it to MM_ICON_SIZE, this lessens the issue. It would probably be ideal to have the definitions in the respective .cpp that use them, but it would make it less convenient to update the values if needed in the future.

* Remove unused includes

* Fix linux/macOS compilation

* Hide unused-function errors on non-Windows systems

* Disable signed/unsigned comparison mismatch error

* Remove/Disable more unused variables

Still TODO: check double for loop in Print.cpp

* Remove unused variable that was missed

* Remove unused variables in libraries in the src folder

* Apply temporary fix for subobject linkage error

* Remove/Disable last set of unused variables reported by GCC

* remove redundant for loop

* fix misspelled ifdef check

* Update message on dialog

* Fix hard-coded platform specific modifier keys

* Remove duplicate for loop

* Disable -Wmisleading-indentation warning

* disable -Wswitch warning

* Remove unused local typedefs

* Fix -Wunused-value

* Fix pragma error on Windows from subobject linkage fix

* Fix -Waddress

* Fix null conversions (-Wconversion-null)

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Ocraftyone 2024-07-29 09:00:26 -04:00 committed by GitHub
parent b40853af94
commit b83e16dbdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
187 changed files with 494 additions and 1101 deletions

View file

@ -301,7 +301,6 @@ public:
memDC.SetTextForeground(StateColor::darkModeColorFor(wxColour(144, 144, 144)));
int width = bitmap.GetWidth();
int text_height = memDC.GetTextExtent(text).GetHeight();
int text_width = memDC.GetTextExtent(text).GetWidth();
wxRect text_rect(wxPoint(0, m_action_line_y_position), wxPoint(width, m_action_line_y_position + text_height));
memDC.DrawLabel(text, text_rect, wxALIGN_CENTER);
@ -963,7 +962,7 @@ void GUI_App::post_init()
// Neither wxShowEvent nor wxWindowCreateEvent work reliably.
if (this->preset_updater) { // G-Code Viewer does not initialize preset_updater.
CallAfter([this] {
bool cw_showed = this->config_wizard_startup();
this->config_wizard_startup();
std::string http_url = get_http_url(app_config->get_country_code());
std::string language = GUI::into_u8(current_language_code());
@ -1026,8 +1025,7 @@ void GUI_App::post_init()
try {
std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ;
files_vec.push_back({ lw_t, temp_path.filename().string() });
} catch (const std::exception &ex) {
}
} catch (std::exception&) {}
}
std::sort(files_vec.begin(), files_vec.end(), [](
std::pair<time_t, std::string> &a, std::pair<time_t, std::string> &b) {
@ -1317,7 +1315,6 @@ int GUI_App::download_plugin(std::string name, std::string package_name, Install
.on_complete([&pro_fn, tmp_path, target_file_path](std::string body, unsigned status) {
BOOST_LOG_TRIVIAL(info) << "[download_plugin 2] completed";
bool cancel = false;
int percent = 0;
fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc);
file.write(body.c_str(), body.size());
file.close();
@ -1927,8 +1924,13 @@ void GUI_App::init_app_config()
boost::filesystem::create_directory(data_dir_path);
}
// Change current dirtory of application
chdir(encode_path((Slic3r::data_dir() + "/log").c_str()).c_str());
// Change current directory of application
auto path = encode_path((Slic3r::data_dir() + "/log").c_str());
#ifdef _WIN32
_chdir(path.c_str());
#else
chdir(path.c_str());
#endif
} else {
m_datadir_redefined = true;
}
@ -3365,7 +3367,7 @@ if (res) {
mainframe->refresh_plugin_tips();
// BBS: remove SLA related message
}
} catch (std::exception &e) {
} catch (std::exception&) {
// wxMessageBox(e.what(), "", MB_OK);
}
}
@ -3379,9 +3381,7 @@ void GUI_App::ShowDownNetPluginDlg() {
return;
DownloadProgressDialog dlg(_L("Downloading Bambu Network Plug-in"));
dlg.ShowModal();
} catch (std::exception &e) {
;
}
} catch (std::exception&) {}
}
void GUI_App::ShowUserLogin(bool show)
@ -3396,9 +3396,7 @@ void GUI_App::ShowUserLogin(bool show)
login_dlg = new ZUserLogin();
}
login_dlg->ShowModal();
} catch (std::exception &e) {
;
}
} catch (std::exception&) {}
} else {
if (login_dlg)
login_dlg->EndModal(wxID_OK);
@ -3418,7 +3416,7 @@ void GUI_App::ShowOnlyFilament() {
// BBS: remove SLA related message
}
} catch (std::exception &e) {
} catch (std::exception&) {
// wxMessageBox(e.what(), "", MB_OK);
}
}
@ -3830,10 +3828,10 @@ std::string GUI_App::handle_web_request(std::string cmd)
auto keyCode = key_event_node.get<int>("key");
auto ctrlKey = key_event_node.get<bool>("ctrl");
auto shiftKey = key_event_node.get<bool>("shift");
auto cmdKey = key_event_node.get<bool>("cmd");
wxKeyEvent e(wxEVT_CHAR_HOOK);
#ifdef __APPLE__
auto cmdKey = key_event_node.get<bool>("cmd");
e.SetControlDown(cmdKey);
e.SetRawControlDown(ctrlKey);
#else
@ -4786,8 +4784,6 @@ void GUI_App::start_sync_user_preset(bool with_progress_dlg)
});
}
unsigned int http_code = 200;
/* get list witch need to be deleted*/
std::vector<string> delete_cache_presets = get_delete_cache_presets_lock();
for (auto it = delete_cache_presets.begin(); it != delete_cache_presets.end();) {
@ -5467,7 +5463,7 @@ void GUI_App::show_ip_address_enter_dialog_handler(wxCommandEvent& evt)
void GUI_App::open_preferences(size_t open_on_tab, const std::string& highlight_option)
{
bool app_layout_changed = false;
// bool app_layout_changed = false;
{
// the dialog needs to be destroyed before the call to recreate_GUI()
// or sometimes the application crashes into wxDialogBase() destructor
@ -6500,8 +6496,6 @@ static bool del_win_registry(HKEY hkeyHive, const wchar_t *pszVar, const wchar_t
return false;
if (!bDidntExist) {
DWORD dwDisposition;
HKEY hkey;
iRC = ::RegDeleteKeyExW(hkeyHive, pszVar, KEY_ALL_ACCESS, 0);
if (iRC == ERROR_SUCCESS) {
return true;