Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain De Laage De Bellefaye
LO21-projet
Commits
6db9e1c6
Verified
Commit
6db9e1c6
authored
Jun 11, 2021
by
Romain De Laage De Bellefaye
🌳
Browse files
Resolve segfault when reinitialize and init buffer
parent
f68f69f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
includes/Automate.h
View file @
6db9e1c6
...
...
@@ -125,7 +125,7 @@ class Automate {
Reseau
getReseauCourant
()
{
return
*
itBuffer
;
}
/// initialiser le buffer s'il est vide avec un réseau
void
initialiserBuffer
()
{
buffer
.
clear
();
buffer
.
push_front
(
reseauInit
);
}
void
initialiserBuffer
()
{
buffer
.
clear
();
buffer
.
push_front
(
reseauInit
);
itBuffer
=
buffer
.
begin
();
}
/// Définir le réseau initial de l'automate
void
setReseauInit
(
Reseau
&
r
)
{
reseauInit
=
r
;
h
=
r
.
getHauteur
();
l
=
r
.
getLargeur
();
}
...
...
includes/autocell.h
View file @
6db9e1c6
...
...
@@ -3,6 +3,7 @@
#include
<reseau_cellule_etats.h>
#include
<memory>
#include
<QObject>
#include
<QApplication>
#include
<QPushButton>
...
...
@@ -28,7 +29,7 @@ class AutoCell : public QWidget
{
static
std
::
unique_ptr
<
AutoCell
>
instance
;
Reseau
*
Grille
=
nullptr
;
unique_ptr
<
Reseau
>
Grille
=
nullptr
;
std
::
vector
<
QString
>
listeGrille
;
Q_OBJECT
...
...
src/Automate.cpp
View file @
6db9e1c6
...
...
@@ -40,11 +40,11 @@ void Automate::reinitialiserAutomate(){
delai
=
500
;
delete
fonction
;
delete
regleVoisinage
;
reseauInit
=
Reseau
(
0
,
0
);
buffer
.
clear
();
itBuffer
=
buffer
.
begin
();
h
=
0
;
l
=
0
;
reseauInit
=
Reseau
(
0
,
0
);
year
=
2000
;
author
=
"Anonym"
;
desc
=
""
;
...
...
src/autocell.cpp
View file @
6db9e1c6
...
...
@@ -213,8 +213,8 @@ void AutoCell::afficherGrille(Reseau* Grille)
{
win_grid
=
new
QWidget
;
unsigned
int
l
=
Grille
->
getLargeur
();
unsigned
int
h
=
Grille
->
getHauteur
();
int
l
=
Grille
->
getLargeur
();
int
h
=
Grille
->
getHauteur
();
delete
grid
;
grid
=
new
QTableWidget
(
h
,
l
,
win_grid
);
...
...
@@ -280,9 +280,7 @@ void AutoCell::initialiserGrille(){
return
;
}
delete
Grille
;
this
->
Grille
=
new
Reseau
(
h
,
l
);
this
->
Grille
.
reset
(
new
Reseau
(
h
,
l
));
if
(
check_aleatoire
->
isChecked
())
Grille
->
setAleatoire
();
...
...
@@ -290,8 +288,7 @@ void AutoCell::initialiserGrille(){
QString
nom_grille
=
list_grids
->
currentText
();
if
(
check_load_grid
->
isChecked
())
{
delete
Grille
;
Grille
=
new
Reseau
(
Database
::
getInstance
().
getReseau
(
listeGrille
[
list_grids
->
currentIndex
()
*
2
].
toInt
()));
/// Méthode à implémenter
this
->
Grille
.
reset
(
new
Reseau
(
Database
::
getInstance
().
getReseau
(
listeGrille
[
list_grids
->
currentIndex
()
*
2
].
toInt
())));
QString
str_largeur
;
//str_largeur.setNum(listeGrille[list_grids->currentIndex()*2].toInt());
QString
str_hauteur
;
...
...
@@ -303,10 +300,9 @@ void AutoCell::initialiserGrille(){
//réinitialiser l'automate
Automate
::
getInstance
().
reset
();
this
->
afficherGrille
(
this
->
Grille
);
this
->
afficherGrille
(
this
->
Grille
.
get
()
);
Automate
::
getInstance
().
setReseauInit
(
*
Grille
);
Automate
::
getInstance
().
initialiserBuffer
();
};
void
AutoCell
::
RAZ
(){
delete
grid
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment