[four-in-a-row/arnaudb/new-ui: 7/12] Compile with --experimental-non-null.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [four-in-a-row/arnaudb/new-ui: 7/12] Compile with --experimental-non-null.
- Date: Thu, 19 Dec 2019 19:50:30 +0000 (UTC)
commit c840f79f35cbe53a2db4d57f74889b820824fd42
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Dec 17 20:18:07 2019 +0100
Compile with --experimental-non-null.
src/four-in-a-row.vala | 2 +-
src/game-board-view.vala | 19 +++++++++++++------
src/meson.build | 3 ++-
src/test-ai.vala | 2 +-
src/theme.vala | 2 +-
5 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/src/four-in-a-row.vala b/src/four-in-a-row.vala
index dbe4930..386dc92 100644
--- a/src/four-in-a-row.vala
+++ b/src/four-in-a-row.vala
@@ -25,7 +25,7 @@ private const int SIZE_VSTR = 53;
private const int SPEED_BLINK = 150;
private const int SPEED_MOVE = 35;
private const int SPEED_DROP = 20;
-private const char vlevel [] = { '0','a','b','c','\0' };
+private const char vlevel [] = { '0','a','b','c' };
private const int DEFAULT_WIDTH = 495;
private const int DEFAULT_HEIGHT = 435;
private const string APPNAME_LONG = "Four-in-a-row";
diff --git a/src/game-board-view.vala b/src/game-board-view.vala
index ecbe16f..1f4e71c 100644
--- a/src/game-board-view.vala
+++ b/src/game-board-view.vala
@@ -197,14 +197,18 @@ private class GameBoardView : Gtk.DrawingArea {
internal void refresh_pixmaps() {
/* scale the pixbufs */
- pb_tileset = pb_tileset_raw.scale_simple(tile_size * 6, tile_size, Gdk.InterpType.BILINEAR);
- pb_bground = pb_bground_raw.scale_simple(board_size, board_size, Gdk.InterpType.BILINEAR);
+ Gdk.Pixbuf? pb_tileset_tmp = pb_tileset_raw.scale_simple(tile_size * 6, tile_size,
Gdk.InterpType.BILINEAR);
+ Gdk.Pixbuf? pb_bground_tmp = pb_bground_raw.scale_simple(board_size, board_size,
Gdk.InterpType.BILINEAR);
+ if (pb_tileset_tmp == null || pb_bground_tmp == null)
+ assert_not_reached ();
+ pb_tileset = (!) pb_tileset_tmp;
+ pb_bground = (!) pb_bground_tmp;
}
private bool load_pixmaps() {
string fname;
Gdk.Pixbuf pb_tileset_tmp;
- Gdk.Pixbuf pb_bground_tmp = null;
+ Gdk.Pixbuf? pb_bground_tmp = null;
/* Try the theme pixmaps, fallback to the default and then give up */
while (true) {
@@ -224,7 +228,7 @@ private class GameBoardView : Gtk.DrawingArea {
pb_tileset_raw = pb_tileset_tmp;
if (theme[Prefs.instance.theme_id].fname_bground != null) {
- fname = "/org/gnome/Four-in-a-row/images/" + theme[Prefs.instance.theme_id].fname_bground;
+ fname = "/org/gnome/Four-in-a-row/images/" + ((!) theme[Prefs.instance.theme_id].fname_bground);
try {
pb_bground_tmp = new Gdk.Pixbuf.from_resource(fname);
} catch (Error e) {
@@ -237,7 +241,7 @@ private class GameBoardView : Gtk.DrawingArea {
* derive the background image from the tile set
*/
if (pb_bground_tmp != null) {
- pb_bground_raw = pb_bground_tmp;
+ pb_bground_raw = (!) pb_bground_tmp;
} else {
int raw_tile_size;
int i, j;
@@ -276,7 +280,10 @@ private class GameBoardView : Gtk.DrawingArea {
protected override bool button_press_event(Gdk.EventButton e) {
int x;
- get_window().get_device_position(e.device, out x, null, null);
+ Gdk.Window? window = get_window();
+ if (window == null)
+ assert_not_reached ();
+ ((!) window).get_device_position(e.device, out x, null, null);
return column_clicked(get_column(x));
}
}
diff --git a/src/meson.build b/src/meson.build
index 83e3471..9744346 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -43,7 +43,8 @@ executable(
],
vala_args: [
'--target-glib', '2.44',
- '--vapidir', join_paths(meson.current_source_dir(), 'vapi')
+ '--vapidir', join_paths(meson.current_source_dir(), 'vapi'),
+ '--enable-experimental-non-null'
],
install: true,
install_dir: get_option('bindir')
diff --git a/src/test-ai.vala b/src/test-ai.vala
index 1c3815b..68c7f86 100644
--- a/src/test-ai.vala
+++ b/src/test-ai.vala
@@ -74,7 +74,7 @@ private static inline void test_forward_diagonal_win ()
/* Tests if the AI makes moves so as to take up immediate backward diagonal wins.*/
private static inline void test_backward_diagonal_win ()
{
- assert (playgame ("5422327343142110") == 1);
+ assert (playgame ("5422327343142110") == 1); // TODO no "a"?
assert (playgame ("a1415113315143220") == 2);
assert (playgame ("a547323452213345110") == 1);
assert (playgame ("a4256424426621271412117175776343330") == 3);
diff --git a/src/theme.vala b/src/theme.vala
index 3028d90..e874fcf 100644
--- a/src/theme.vala
+++ b/src/theme.vala
@@ -21,7 +21,7 @@
private struct Theme {
public string title;
public string fname_tileset;
- public string fname_bground;
+ public string? fname_bground;
public string grid_color;
public string player1;
public string player2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]