| 235 | } |
| 236 | |
| 237 | void DebuggerPlugin::onLoadProject( const std::string& projectFolder, |
| 238 | const std::string& projectStatePath ) { |
| 239 | mProjectPath = projectFolder; |
| 240 | |
| 241 | ScopedOp op( [this] { closeProject(); }, |
| 242 | [this] { |
| 243 | auto sdc = getStatusDebuggerController(); |
| 244 | if ( sdc && sdc->getUIBreakpoints() ) { |
| 245 | sdc->getUIBreakpoints()->runOnMainThread( [this, sdc] { |
| 246 | sdc->getUIBreakpoints()->setModel( mBreakpointsModel ); |
| 247 | } ); |
| 248 | } |
| 249 | } ); |
| 250 | |
| 251 | std::string debuggerStatePath( projectStatePath + "debugger.json" ); |
| 252 | std::string data; |
| 253 | if ( !FileSystem::fileGet( debuggerStatePath, data ) ) |
| 254 | return; |
| 255 | |
| 256 | auto sdc = getStatusDebuggerController(); |
| 257 | |
| 258 | json j; |
| 259 | try { |
| 260 | j = json::parse( data, nullptr, true, true ); |
| 261 | if ( j.contains( "config" ) && j["config"].is_object() ) { |
| 262 | auto& config = j["config"]; |
| 263 | mCurDebugger = config.value( "debugger", "" ); |
| 264 | mCurConfiguration = config.value( "configuration", "" ); |
| 265 | mExpressions.clear(); |
| 266 | if ( config.contains( "expressions" ) && config["expressions"].is_array() ) { |
| 267 | auto& exps = config["expressions"]; |
| 268 | if ( mExpressionsHolder ) |
| 269 | mExpressionsHolder->clear( true ); |
| 270 | for ( const auto& expression : exps ) { |
| 271 | if ( expression.is_string() ) { |
| 272 | mExpressions.push_back( expression.get<std::string>() ); |
| 273 | if ( mExpressionsHolder ) { |
| 274 | mExpressionsHolder->addChild( |
| 275 | std::make_shared<ModelVariableNode>( expression, 0 ) ); |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | if ( sdc && sdc->getWidget() && sdc->getUIExpressions() ) |
| 281 | sdc->getUIExpressions()->setModel( mExpressionsHolder->getModel() ); |
| 282 | } |
| 283 | |
| 284 | if ( config.contains( "breakpoints" ) && config["breakpoints"].is_object() ) { |
| 285 | BreakpointsHolder breakpoints; |
| 286 | for ( auto& [key, value] : config["breakpoints"].items() ) { |
| 287 | if ( value.is_array() ) { |
| 288 | BreakpointsSet set; |
| 289 | for ( auto& jbp : value ) { |
| 290 | SourceBreakpointStateful bp; |
| 291 | bp.line = jbp.value( "line", 1 ); |
| 292 | bp.enabled = jbp.value( "enabled", true ); |
| 293 | if ( bp.line > 0 ) |
| 294 | set.insert( std::move( bp ) ); |
nothing calls this directly
no test coverage detected