| 249 | } |
| 250 | |
| 251 | bool NewFunctionDialog::parseUserInput() |
| 252 | { |
| 253 | QString error_message; |
| 254 | m_cpu.GetSymbolGuardian().Read([&](const ccc::SymbolDatabase& database) { |
| 255 | m_name = parseName(error_message); |
| 256 | if (!error_message.isEmpty()) |
| 257 | return; |
| 258 | |
| 259 | m_address = parseAddress(error_message); |
| 260 | if (!error_message.isEmpty()) |
| 261 | return; |
| 262 | |
| 263 | m_size = 0; |
| 264 | switch (functionSizeType()) |
| 265 | { |
| 266 | case FILL_EXISTING_FUNCTION: |
| 267 | { |
| 268 | std::optional<u32> fill_existing_function_size = fillExistingFunctionSize(m_address, database); |
| 269 | if (!fill_existing_function_size.has_value()) |
| 270 | { |
| 271 | error_message = tr("No existing function found."); |
| 272 | return; |
| 273 | } |
| 274 | |
| 275 | m_size = *fill_existing_function_size; |
| 276 | |
| 277 | break; |
| 278 | } |
| 279 | case FILL_EMPTY_SPACE: |
| 280 | { |
| 281 | std::optional<u32> fill_space_size = fillEmptySpaceSize(m_address, database); |
| 282 | if (!fill_space_size.has_value()) |
| 283 | { |
| 284 | error_message = tr("No next symbol found."); |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | m_size = *fill_space_size; |
| 289 | |
| 290 | break; |
| 291 | } |
| 292 | case CUSTOM_SIZE: |
| 293 | { |
| 294 | m_size = m_ui.customSizeSpinBox->value(); |
| 295 | break; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | if (m_size == 0 || m_size > 256 * 1024 * 1024) |
| 300 | { |
| 301 | error_message = tr("Size is invalid."); |
| 302 | return; |
| 303 | } |
| 304 | |
| 305 | if (m_size % 4 != 0) |
| 306 | { |
| 307 | error_message = tr("Size is not a multiple of 4."); |
| 308 | return; |
nothing calls this directly
no test coverage detected