| 2581 | |
| 2582 | |
| 2583 | bool Window::updateProgram(const QString &fileName) |
| 2584 | // ---------------------------------------------------------------------------- |
| 2585 | // When a file has changed, reload corresponding XL program |
| 2586 | // ---------------------------------------------------------------------------- |
| 2587 | { |
| 2588 | bool hadError = false; |
| 2589 | QFileInfo fileInfo(fileName); |
| 2590 | QString absoluteFilePath = fileInfo.absoluteFilePath(); |
| 2591 | text fn = +absoluteFilePath; |
| 2592 | XL::SourceFile *sf = NULL; |
| 2593 | |
| 2594 | if (!isUntitled) |
| 2595 | { |
| 2596 | sf = &xlRuntime->files[fn]; |
| 2597 | // Clean menus and reload XL program |
| 2598 | resetTaoMenus(); |
| 2599 | if (!sf->tree) |
| 2600 | { |
| 2601 | if (taoWidget->loadFile(fn)) |
| 2602 | hadError = true; |
| 2603 | } |
| 2604 | |
| 2605 | // Check if we can access the file |
| 2606 | if (!fileInfo.isWritable()) |
| 2607 | sf->readOnly = true; |
| 2608 | } |
| 2609 | else |
| 2610 | { |
| 2611 | if (taoWidget->loadFile(fn)) |
| 2612 | return true; |
| 2613 | sf = &xlRuntime->files[fn]; |
| 2614 | } |
| 2615 | |
| 2616 | taoWidget->updateProgram(sf); |
| 2617 | taoWidget->updateGL(); |
| 2618 | return hadError; |
| 2619 | } |
| 2620 | |
| 2621 | |
| 2622 | void Window::markChanged(bool changed) |