Changeset d26c3b950032d169b2d19dfccdf444256264c162
- Timestamp:
- 09/10/09 05:37:41 (4 years ago)
- Author:
- Armin Burgmeier <armin@…>
- git-author:
- Armin Burgmeier <armin@arbur.net> / 2009-09-09T23:30:56Z-0400
- Parents:
- 81f1f55f4c81c36b08fffb6d8123e7b0be1fdcd5
- Children:
- b483a11d3443e16937dd7c8586c1a068e68e6bbd
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2009-09-09T23:37:41Z-0400
- Message:
-
remote-url-open: Made the UNIQUE_GOBBY_CONNECT case exception-safe
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r81f1f55
|
rd26c3b9
|
|
| | 1 | 2009-09-09 Armin Burgmeier <armin@arbur.net> |
| | 2 | |
| | 3 | * code/window.cpp (on_message_received): Don't leak the uris vector |
| | 4 | when an exception is thrown. |
| | 5 | |
| 1 | 6 | 2009-09-09 Benjamin Herr <ben@0x539.de> |
| 2 | 7 | |
-
|
r81f1f55
|
rd26c3b9
|
|
| 241 | 241 | try |
| 242 | 242 | { |
| | 243 | struct uris_holder |
| | 244 | { |
| | 245 | uris_holder(gchar** uris): uris(uris) {} |
| | 246 | ~uris_holder() { if(uris) g_strfreev(uris); } |
| | 247 | operator gchar* const*() const { return uris; } |
| | 248 | |
| | 249 | gchar** uris; |
| | 250 | |
| | 251 | private: |
| | 252 | uris_holder(const uris_holder&); |
| | 253 | uris_holder& operator=(const uris_holder&); |
| | 254 | }; |
| | 255 | |
| 243 | 256 | switch (command) |
| 244 | 257 | { |
| … |
… |
|
| 250 | 263 | case UNIQUE_OPEN: |
| 251 | 264 | { |
| 252 | | gchar** uris = unique_message_data_get_uris(message); |
| 253 | | if (!uris || !uris[0]) |
| | 265 | uris_holder uris( |
| | 266 | unique_message_data_get_uris(message)); |
| | 267 | if(!uris || !uris[0]) |
| 254 | 268 | return UNIQUE_RESPONSE_FAIL; |
| 255 | 269 | if(uris[1]) // multiple files? |
| … |
… |
|
| 257 | 271 | TaskOpenMultiple* task = |
| 258 | 272 | new TaskOpenMultiple(m_commands_file); |
| 259 | | for (const gchar* const* p = uris; *p; ++p) |
| | 273 | for(const gchar* const* p = uris; *p; ++p) |
| 260 | 274 | task->add_file(*p); |
| 261 | 275 | m_commands_file.set_task(task); |
| … |
… |
|
| 268 | 282 | m_commands_file.set_task(task); |
| 269 | 283 | } |
| 270 | | g_strfreev(uris); |
| 271 | 284 | return UNIQUE_RESPONSE_OK; |
| 272 | 285 | } |
| 273 | 286 | case UNIQUE_GOBBY_CONNECT: |
| 274 | 287 | { |
| 275 | | gchar** uris = unique_message_data_get_uris(message); |
| | 288 | uris_holder uris(unique_message_data_get_uris(message)); |
| 276 | 289 | if(!uris || !uris[0]) |
| 277 | 290 | return UNIQUE_RESPONSE_FAIL; |
| 278 | | // TODO: I do not have a very strong intuition that |
| 279 | | // this is not going to throw, ever. We should |
| 280 | | // probably handle that. |
| 281 | 291 | for(const gchar* const* p = uris; *p; ++p) |
| 282 | 292 | { |
| 283 | | if(!g_str_has_prefix(*p, "infinote://")) |
| 284 | | { |
| 285 | | g_strfreev(uris); |
| | 293 | const gchar protocol[] = "infinote://"; |
| | 294 | if(!g_str_has_prefix(*p, protocol)) |
| 286 | 295 | return UNIQUE_RESPONSE_FAIL; |
| 287 | | } |
| 288 | | connect_to_host(*p + sizeof("infinote://")-1); |
| | 296 | connect_to_host(*p + sizeof(protocol) - 1); |
| 289 | 297 | } |
| 290 | | g_strfreev(uris); |
| 291 | 298 | return UNIQUE_RESPONSE_OK; |
| 292 | 299 | } |
| … |
… |
|
| 294 | 301 | return UNIQUE_RESPONSE_PASSTHROUGH; |
| 295 | 302 | } |
| 296 | | } catch (...) { |
| | 303 | } |
| | 304 | // For example, connect_to_host might throw Glib::ThreadError |
| | 305 | catch(const Glib::Exception& error) |
| | 306 | { |
| | 307 | // TODO: Do we want to show a dialog here? |
| | 308 | g_warning("Failed to process IPC message: %s", error.what().c_str()); |
| | 309 | return UNIQUE_RESPONSE_FAIL; |
| | 310 | } |
| | 311 | catch (...) |
| | 312 | { |
| 297 | 313 | g_assert_not_reached(); |
| 298 | 314 | return UNIQUE_RESPONSE_FAIL; |