diff options
author | scratko <m@scratko.xyz> | 2024-11-21 00:42:10 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-11-21 00:50:56 +0300 |
commit | 0b72fabadec642dcecfe861c56dfeddb0c82a898 (patch) | |
tree | 76d8a003db2c45bd0a94753ab921fc07d080f970 /puzzle.hpp | |
parent | 503e7350fa3d8065e2f4814181664382154dc702 (diff) | |
download | picture-puzzle-0b72fabadec642dcecfe861c56dfeddb0c82a898.tar.gz picture-puzzle-0b72fabadec642dcecfe861c56dfeddb0c82a898.tar.bz2 picture-puzzle-0b72fabadec642dcecfe861c56dfeddb0c82a898.zip |
Fixed memory leak
The image widget is responsible for deleting the loaded part of the image
Check for correct type of selected file
Error checking after image upload
Diffstat (limited to 'puzzle.hpp')
-rw-r--r-- | puzzle.hpp | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -4,12 +4,13 @@ #include <FL/Enumerations.H> #include <FL/Fl_Button.H> #include <FL/Fl_Window.H> +#include <FL/Fl_PNG_Image.H> #include <string> #include <vector> #include <memory> enum { - puzzle_pieces = 9, + puzzle_pieces = 9, // including empty puzzle puzzles_per_side = 3, puzzle_size = 100, spacing = 5 @@ -19,8 +20,12 @@ class Puzzle : public Fl_Button{ public: unsigned char sequence_number; std::string path; + Fl_PNG_Image *stored_img_pointer; Puzzle(int x, int y) - : Fl_Button(x, y, puzzle_size, puzzle_size) {} + : Fl_Button(x, y, puzzle_size, puzzle_size), + stored_img_pointer(nullptr) { + } + ~Puzzle() { delete stored_img_pointer; } }; class GameParams { @@ -40,7 +45,9 @@ private: Fl_Window *win; std::string cur_directory; - GameParams(Fl_Window *a_win = nullptr) : win(a_win) {} + GameParams(Fl_Window *a_win = nullptr) + : win(a_win) + {} void CalculateStandardPuzzlePos(); void ResetFreePuzzles(); void NextUntestedPuzzles(); |