Do not reconstruct user config files if the configuration file is broken, just notify the user that it's broken. Worst case scenario will have to reset it, addresses SpartanJ/ecode#827.

This commit is contained in:
Martín Lucas Golini
2026-02-27 01:19:55 -03:00
parent 3b671bbb97
commit 8cd44ed8c5
11 changed files with 853 additions and 7 deletions

View File

@@ -416,13 +416,27 @@ static std::initializer_list<std::string> DebuggerCommandList = {
"toggle-status-app-debugger",
};
void DebuggerPlugin::displayBrokenUserConfigFileWarning() {
if ( nullptr == getUISceneNode() )
return;
NotificationCenter::instance()->addNotification(
String::format( i18n( "error_debugger_config_parsing",
"Debugger Plugin - Error parsing Debugger config:\n%s" )
.toUtf8(),
mConfigFileError ),
Seconds( 5 ) );
}
void DebuggerPlugin::loadDAPConfig( const std::string& path, bool updateConfigFile ) {
std::string data;
if ( !FileSystem::fileGet( path, data ) )
return;
if ( updateConfigFile )
if ( updateConfigFile ) {
mConfigHash = String::hash( data );
mBrokenUserConfigFile = false;
}
json j;
try {
@@ -431,6 +445,16 @@ void DebuggerPlugin::loadDAPConfig( const std::string& path, bool updateConfigFi
Log::error( "DebuggerPlugin::load - Error parsing config from path %s, error: %s, config "
"file content:\n%s",
path.c_str(), e.what(), data.c_str() );
if ( !updateConfigFile )
return;
else {
// updateConfigFile = true is always the user config file
// file recreation logic has been disabled
mBrokenUserConfigFile = true;
mConfigFileError = e.what();
displayBrokenUserConfigFileWarning();
return;
}
// Recreate it
j = json::parse( "{\n \"config\":{},\n \"dap\":{},\n \"keybindings\":{},\n}\n", nullptr,
true, true );
@@ -706,6 +730,9 @@ PluginRequestHandle DebuggerPlugin::processMessage( const PluginMessage& msg ) {
if ( !mInitialized )
updateUI();
if ( mBrokenUserConfigFile )
displayBrokenUserConfigFileWarning();
break;
}
default: