[Commits] [wesnoth/wesnoth] 2b72e4: Cleanup image::save_image()

GitHub noreply at github.com
Fri Apr 10 04:25:37 UTC 2015


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 2b72e4250a0a5a7cec9eb5380b90300306e9a72d
      https://github.com/wesnoth/wesnoth/commit/2b72e4250a0a5a7cec9eb5380b90300306e9a72d
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-09 (Thu, 09 Apr 2015)

  Changed paths:
    M src/image.cpp

  Log Message:
  -----------
  Cleanup image::save_image()

Replaces a short-lived SDL_Surface and accompanying SDL_FreeSurface call
with a surface object and fixes some indentation.


  Commit: dbe7e3e28ff043c86f0d22814b648b80941765a8
      https://github.com/wesnoth/wesnoth/commit/dbe7e3e28ff043c86f0d22814b648b80941765a8
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-09 (Thu, 09 Apr 2015)

  Changed paths:
    M src/image.cpp

  Log Message:
  -----------
  Use filesystem::ends_with() in image::save_image()

Makes the code more readable. Also, made sure the file extension itself
is considered and not just the last three characters.


  Commit: a17169a406e141ac8acdf7819ec75c9b7c65f385
      https://github.com/wesnoth/wesnoth/commit/a17169a406e141ac8acdf7819ec75c9b7c65f385
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-09 (Thu, 09 Apr 2015)

  Changed paths:
    M src/image.cpp
    M src/image.hpp

  Log Message:
  -----------
  Make image::save_image() return the success state


  Commit: db28dca52c078fa4f32d80641c694ddd7a08d876
      https://github.com/wesnoth/wesnoth/commit/db28dca52c078fa4f32d80641c694ddd7a08d876
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-10 (Fri, 10 Apr 2015)

  Changed paths:
    M src/gui/dialogs/screenshot_notification.cpp
    M src/gui/dialogs/screenshot_notification.hpp
    M src/hotkey/command_executor.cpp
    M src/tests/gui/test_gui2.cpp

  Log Message:
  -----------
  gui2/tscreenshot_notification: Don't obtain file size from caller

The caller's provided size is notoriously unreliable right now --
especially after the addition of PNG support -- because it's obtained
from display::screenshot(), which just does some math voodoo to
calculate the *expected* size of a BMP file and sticks to that.

stat-ing a file is cheap, and simplifies our constructor's signature.
This also fixes PNG files having the wrong size reported.


  Commit: a62914e9f25d142917343c5d88d955382bd07b56
      https://github.com/wesnoth/wesnoth/commit/a62914e9f25d142917343c5d88d955382bd07b56
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-10 (Fri, 10 Apr 2015)

  Changed paths:
    M src/display.cpp
    M src/display.hpp

  Log Message:
  -----------
  display: Return error status from display::screenshot() instead of file size

This makes it so errors in image::save_image() are printed to stderr
using our log facilities before returning, and also propagates the
function's result to screenshot()'s callers instead of a computed
screenshot size that doesn't hold true for PNG images.

Additionally, a couple of existing error messages have been reworded and
are now emitted through the log facilities instead of being sent
directly to stderr.


  Commit: 1c0ead2cd728b74be355c540f5dbeb519d936b8c
      https://github.com/wesnoth/wesnoth/commit/1c0ead2cd728b74be355c540f5dbeb519d936b8c
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-10 (Fri, 10 Apr 2015)

  Changed paths:
    M src/hotkey/command_executor.cpp

  Log Message:
  -----------
  ui: Check whether screenshot creation succeeded and report otherwise

This displays an actual error message in the UI if screenshot creation
fails, instead of just saying "Screenshot Done" and assuming the best
(???).

NOTE: I could make it so display::screenshot() returns an object
including both the operation's result and the SDL_GetError text if
applicable, but I don't see the point for complicating this code further
right now, since it's relatively rare for screenshot creation to fail.
Furthermore, SDL_GetError's text is not translatable, which is a major
inconvenience for us.

The current error message is horribly general in scope and may not
accurately represent the actual issue at hand, but I think it's better
than asking users to check "the log" (which basic users don't really
know about) and read text that they might not even understand if they
don't know English. Someone who really wants to know what's going on
will ask us for help and we'll tell them how to access the log with
details anyway.


  Commit: 02223affc63bea92549ac9490e27321d5ae79c8d
      https://github.com/wesnoth/wesnoth/commit/02223affc63bea92549ac9490e27321d5ae79c8d
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-10 (Fri, 10 Apr 2015)

  Changed paths:
    M src/display.cpp

  Log Message:
  -----------
  display: Comment out calls to SDL_GetError from display::screenshot()

The SDL_SavePNG path (from image::save_image()) results in oblique error
messages when file creation fails for any reason, and these messages
don't make sense to anyone who is not familiarized with its
implementation.


  Commit: 6a2abfcb78158d70deae01d7c13be69729d188d6
      https://github.com/wesnoth/wesnoth/commit/6a2abfcb78158d70deae01d7c13be69729d188d6
  Author: Ignacio R. Morelle <shadowm at wesnoth.org>
  Date:   2015-04-10 (Fri, 10 Apr 2015)

  Changed paths:
    M src/hotkey/command_executor.cpp

  Log Message:
  -----------
  ui: Minor clean-up in hotkey::execute_command()

Constness and indentation, no functional changes.


Compare: https://github.com/wesnoth/wesnoth/compare/5a55d7ee012f...6a2abfcb7815


More information about the Commits mailing list