Changeset 3da60b7045c13b5d6d3156113bd36d2b7390e552
- Timestamp:
- 04/27/09 19:12:39 (4 years ago)
- Author:
- Benjamin Herr <ben@…>
- Parents:
- 2f98c8dc4105d1f90e7cd4a58d3013369e77b311
- Children:
- 83d481283330829f52cdfed0a4316e07f1e0c5d6
- git-committer:
- Benjamin Herr <ben@0x539.de> / 2009-04-27T19:12:39Z+0200
- Message:
-
tasks: fixed starting tasks while an old task exists
2009-04-27 Benjamin Herr <ben@…>
- code/commands/file-commands.cpp:
- code/commands/file-commands.hpp:
- code/commands/file-tasks/task-new.cpp:
- code/commands/file-tasks/task-new.hpp:
- code/commands/file-tasks/task-open-file.cpp:
- code/commands/file-tasks/task-open-file.hpp:
- code/commands/file-tasks/task-open-location.cpp:
- code/commands/file-tasks/task-open-location.hpp:
- code/commands/file-tasks/task-open.cpp:
- code/commands/file-tasks/task-open.hpp:
- code/commands/file-tasks/task-save-all.cpp:
- code/commands/file-tasks/task-save-all.hpp:
- code/commands/file-tasks/task-save.cpp:
- code/commands/file-tasks/task-save.hpp: Split most of all Task
constructors into a separate run() member function that is called by
FileCommands::set_task after resetting its current task. This ensures
that a new task only gets to mess with stuff after the old one's
destructor has been run.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r2f98c8d
|
r3da60b7
|
|
| | 1 | 2009-04-27 Benjamin Herr <ben@0x539.de> |
| | 2 | |
| | 3 | * code/commands/file-commands.cpp: |
| | 4 | * code/commands/file-commands.hpp: |
| | 5 | * code/commands/file-tasks/task-new.cpp: |
| | 6 | * code/commands/file-tasks/task-new.hpp: |
| | 7 | * code/commands/file-tasks/task-open-file.cpp: |
| | 8 | * code/commands/file-tasks/task-open-file.hpp: |
| | 9 | * code/commands/file-tasks/task-open-location.cpp: |
| | 10 | * code/commands/file-tasks/task-open-location.hpp: |
| | 11 | * code/commands/file-tasks/task-open.cpp: |
| | 12 | * code/commands/file-tasks/task-open.hpp: |
| | 13 | * code/commands/file-tasks/task-save-all.cpp: |
| | 14 | * code/commands/file-tasks/task-save-all.hpp: |
| | 15 | * code/commands/file-tasks/task-save.cpp: |
| | 16 | * code/commands/file-tasks/task-save.hpp: Split most of all Task |
| | 17 | constructors into a separate run() member function that is called by |
| | 18 | FileCommands::set_task after resetting its current task. This ensures |
| | 19 | that a new task only gets to mess with stuff after the old one's |
| | 20 | destructor has been run. |
| | 21 | |
| 1 | 22 | 2009-04-26 Armin Burgmeier <armin@arbur.net> |
| 2 | 23 | |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 147 | 147 | *this, &FileCommands::on_task_finished)); |
| 148 | 148 | m_task.reset(task); |
| | 149 | task->run(); |
| 149 | 150 | } |
| 150 | 151 | |
-
|
rd9e7c10
|
r3da60b7
|
|
| 51 | 51 | virtual ~Task() = 0; |
| 52 | 52 | |
| | 53 | virtual void run() = 0; |
| 53 | 54 | void finish(); |
| 54 | 55 | |
-
|
re6d3292
|
r3da60b7
|
|
| 23 | 23 | Task(file_commands) |
| 24 | 24 | { |
| | 25 | } |
| | 26 | |
| | 27 | Gobby::TaskNew::~TaskNew() |
| | 28 | { |
| | 29 | get_document_location_dialog().hide(); |
| | 30 | } |
| | 31 | |
| | 32 | void Gobby::TaskNew::run() |
| | 33 | { |
| 25 | 34 | DocumentLocationDialog& dialog = get_document_location_dialog(); |
| 26 | 35 | |
| … |
… |
|
| 29 | 38 | dialog.set_document_name(_("New Document")); |
| 30 | 39 | dialog.present(); |
| 31 | | } |
| 32 | | |
| 33 | | Gobby::TaskNew::~TaskNew() |
| 34 | | { |
| 35 | | get_document_location_dialog().hide(); |
| 36 | 40 | } |
| 37 | 41 | |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 30 | 30 | TaskNew(FileCommands& file_commands); |
| 31 | 31 | virtual ~TaskNew(); |
| | 32 | virtual void run(); |
| 32 | 33 | |
| 33 | 34 | protected: |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 25 | 25 | Gtk::FILE_CHOOSER_ACTION_OPEN) |
| 26 | 26 | { |
| | 27 | } |
| | 28 | |
| | 29 | void Gobby::TaskOpenFile::run() |
| | 30 | { |
| 27 | 31 | m_file_dialog.signal_response().connect(sigc::mem_fun( |
| 28 | 32 | *this, &TaskOpenFile::on_file_response)); |
| … |
… |
|
| 44 | 48 | m_open_task->signal_finished().connect( |
| 45 | 49 | sigc::mem_fun(*this, &TaskOpenFile::finish)); |
| | 50 | m_open_task->run(); |
| 46 | 51 | } |
| 47 | 52 | else |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 31 | 31 | TaskOpenFile(FileCommands& file_commands); |
| 32 | 32 | |
| | 33 | virtual void run(); |
| | 34 | |
| 33 | 35 | private: |
| 34 | 36 | void on_file_response(int response_id); |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 24 | 24 | Task(file_commands), m_location_dialog(get_parent()) |
| 25 | 25 | { |
| | 26 | } |
| | 27 | |
| | 28 | void Gobby::TaskOpenLocation::run() |
| | 29 | { |
| 26 | 30 | m_location_dialog.signal_response().connect( |
| 27 | 31 | sigc::mem_fun( *this, &TaskOpenLocation::on_response)); |
| … |
… |
|
| 45 | 49 | m_open_task->signal_finished().connect( |
| 46 | 50 | sigc::mem_fun(*this, &TaskOpenLocation::finish)); |
| | 51 | m_open_task->run(); |
| 47 | 52 | } |
| 48 | 53 | else |
-
|
rd9e7c10
|
r3da60b7
|
|
| 32 | 32 | TaskOpenLocation(FileCommands& file_commands); |
| 33 | 33 | |
| | 34 | virtual void run(); |
| | 35 | |
| 34 | 36 | private: |
| 35 | 37 | void on_response(int response_id); |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 23 | 23 | const Glib::RefPtr<Gio::File>& file): |
| 24 | 24 | Task(file_commands), m_file(file) |
| | 25 | { |
| | 26 | } |
| | 27 | |
| | 28 | Gobby::TaskOpen::~TaskOpen() |
| | 29 | { |
| | 30 | if(m_handle != get_status_bar().invalid_handle()) |
| | 31 | get_status_bar().remove_message(m_handle); |
| | 32 | get_document_location_dialog().hide(); |
| | 33 | } |
| | 34 | |
| | 35 | void Gobby::TaskOpen::run() |
| 25 | 36 | { |
| 26 | 37 | static const gchar* const ATTR_DISPLAY_NAME = |
| … |
… |
|
| 50 | 61 | ex.what()), false)); |
| 51 | 62 | } |
| 52 | | } |
| 53 | | |
| 54 | | Gobby::TaskOpen::~TaskOpen() |
| 55 | | { |
| 56 | | if(m_handle != get_status_bar().invalid_handle()) |
| 57 | | get_status_bar().remove_message(m_handle); |
| 58 | | get_document_location_dialog().hide(); |
| 59 | 63 | } |
| 60 | 64 | |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 32 | 32 | virtual ~TaskOpen(); |
| 33 | 33 | |
| | 34 | virtual void run(); |
| | 35 | |
| 34 | 36 | private: |
| 35 | 37 | void on_query_info(const Glib::RefPtr<Gio::AsyncResult>& result); |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 22 | 22 | Task(file_commands) |
| 23 | 23 | { |
| | 24 | } |
| | 25 | |
| | 26 | void Gobby::TaskSaveAll::run() { |
| 24 | 27 | typedef Gtk::Notebook_Helpers::PageList PageList; |
| 25 | 28 | PageList& pages = get_folder().pages(); |
| … |
… |
|
| 92 | 95 | m_task->signal_finished().connect(sigc::mem_fun( |
| 93 | 96 | *this, &TaskSaveAll::on_finished)); |
| | 97 | m_task->run(); |
| 94 | 98 | } |
| 95 | 99 | } |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 31 | 31 | TaskSaveAll(FileCommands& file_commands); |
| 32 | 32 | |
| | 33 | virtual void run(); |
| | 34 | |
| 33 | 35 | private: |
| 34 | 36 | void on_document_removed(DocWindow& document); |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 29 | 29 | m_document(&document) |
| 30 | 30 | { |
| | 31 | get_folder().signal_document_removed().connect( |
| | 32 | sigc::mem_fun( *this, &TaskSave::on_document_removed)); |
| | 33 | } |
| | 34 | |
| | 35 | void Gobby::TaskSave::run() { |
| | 36 | if(!m_document) |
| | 37 | { |
| | 38 | finish(); |
| | 39 | return; |
| | 40 | } |
| | 41 | |
| 31 | 42 | m_file_dialog.signal_response().connect(sigc::mem_fun( |
| 32 | 43 | *this, &TaskSave::on_response)); |
| 33 | | get_folder().signal_document_removed().connect( |
| 34 | | sigc::mem_fun( *this, &TaskSave::on_document_removed)); |
| 35 | 44 | |
| 36 | 45 | const DocumentInfoStorage::Info* info = |
| 37 | 46 | get_document_info_storage().get_info( |
| 38 | | document.get_info_storage_key()); |
| | 47 | m_document->get_info_storage_key()); |
| 39 | 48 | |
| 40 | 49 | if(info != NULL && !info->uri.empty()) |
| … |
… |
|
| 45 | 54 | { |
| 46 | 55 | m_file_dialog.set_current_name( |
| 47 | | document.get_title()); |
| | 56 | m_document->get_title()); |
| 48 | 57 | } |
| 49 | 58 | |
| … |
… |
|
| 77 | 86 | // The document we are about to save was removed. |
| 78 | 87 | if(m_document == &document) |
| 79 | | finish(); |
| | 88 | { |
| | 89 | if(m_running) |
| | 90 | finish(); |
| | 91 | else |
| | 92 | m_document = NULL; |
| | 93 | } |
| 80 | 94 | } |
-
|
r9f4b8f3
|
r3da60b7
|
|
| 30 | 30 | FileChooser::Dialog m_file_dialog; |
| 31 | 31 | DocWindow* m_document; |
| | 32 | bool m_running; |
| 32 | 33 | |
| 33 | 34 | public: |
| 34 | 35 | TaskSave(FileCommands& file_commands, DocWindow& document); |
| | 36 | virtual void run(); |
| 35 | 37 | |
| 36 | 38 | void on_response(int response_id); |