[gnome-games] Fix engine string being freed (bug in vala with string properties)
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Fix engine string being freed (bug in vala with string properties)
- Date: Tue, 18 Jan 2011 22:46:22 +0000 (UTC)
commit 579165c15e3d851c8ddcc9d57f0d6e3df64e6079
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Jan 19 08:00:37 2011 +1100
Fix engine string being freed (bug in vala with string properties)
glchess/src/chess-engine-cecp.vala | 2 +-
glchess/src/chess-engine-uci.vala | 2 +-
glchess/src/chess-game.vala | 19 ++++++++-----------
3 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/glchess/src/chess-engine-cecp.vala b/glchess/src/chess-engine-cecp.vala
index c0b561c..a5008c7 100644
--- a/glchess/src/chess-engine-cecp.vala
+++ b/glchess/src/chess-engine-cecp.vala
@@ -82,7 +82,7 @@ public class ChessEngineCECP : ChessEngine
{
/* Stop the AI from automatically moving in response to this one */
write_line ("force");
- write_line (move.engine);
+ write_line (move.get_engine ());
}
moving = false;
}
diff --git a/glchess/src/chess-engine-uci.vala b/glchess/src/chess-engine-uci.vala
index 93f10d5..842cd5f 100644
--- a/glchess/src/chess-engine-uci.vala
+++ b/glchess/src/chess-engine-uci.vala
@@ -31,7 +31,7 @@ public class ChessEngineUCI : ChessEngine
{
if (position_command == "position startpos")
position_command += " moves";
- position_command += " " + move.engine;
+ position_command += " " + move.get_engine ();
write_line (position_command);
}
diff --git a/glchess/src/chess-game.vala b/glchess/src/chess-game.vala
index 81a0536..2d924f6 100644
--- a/glchess/src/chess-game.vala
+++ b/glchess/src/chess-game.vala
@@ -163,18 +163,15 @@ public class ChessMove
}
/* Move suitable for a chess engine (CECP/UCI) */
- public string engine
+ public string get_engine ()
{
- get
- {
- var builder = new StringBuilder ();
- const char promotion_symbols[] = {' ', 'r', 'n', 'b', 'q', ' '};
- if (promotion_piece != null)
- builder.append_printf ("%c%d%c%d%c", 'a' + f0, r0 + 1, 'a' + f1, r1 + 1, promotion_symbols[promotion_piece.type]);
- else
- builder.append_printf ("%c%d%c%d", 'a' + f0, r0 + 1, 'a' + f1, r1 + 1);
- return builder.str;
- }
+ var builder = new StringBuilder ();
+ const char promotion_symbols[] = {' ', 'r', 'n', 'b', 'q', ' '};
+ if (promotion_piece != null)
+ builder.append_printf ("%c%d%c%d%c", 'a' + f0, r0 + 1, 'a' + f1, r1 + 1, promotion_symbols[promotion_piece.type]);
+ else
+ builder.append_printf ("%c%d%c%d", 'a' + f0, r0 + 1, 'a' + f1, r1 + 1);
+ return builder.str;
}
public ChessMove copy ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]