Salut, je souhaiterais delete un foncteur dans l'appel de celui-ci même.

Code cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
void FileDialog::onFileSelected(Label* label) {
                std::string fileName = label->getText();
                sf::Color color = label->getForegroundColor();
                for (unsigned int i = 0; i < pFiles.getChildren().size(); i++) {
                    getListener().removeCommand("f"+static_cast<Label*>(pFiles.getChildren()[i])->getText());
                }
                pFiles.removeAll();
                if (color == sf::Color::Red) {
                    std::string currentDir = lTop.getText();
                    currentDir += "/"+fileName;
                    lTop.setText(currentDir);
                    if (DIR* current = opendir(fileName.c_str())) {
                        dirent *ent;
                        std::string fileNames;
                        unsigned int i = 0;
                        while ((ent = readdir(current)) != NULL) {
                            if (strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..")) {
                                fileNames = std::string(ent->d_name);
                                Label* lFile = new Label(rw, math::Vec3f(0, 0, 0), math::Vec3f(800, 600, 0), font, "");
                                pFiles.addChild(lFile);
                                lFile->setParent(&pFiles);
                                lFile->setRelToParentLayout(math::Vec3f(0, 0.05 * i, 1, 0.05));
                                lFile->setText(sf::String(fileNames));
                                struct stat path_stat;
                                stat(fileNames.c_str(), &path_stat);
                                if(!S_ISREG(path_stat.st_mode))
                                    lFile->setForegroundColor(sf::Color::Red);
                                i++;
                            }
                        }
                    }
                }
            }

onFileSelected est appelé via un foncteur que je delete. (je delete aussi l'argument du foncteur (Le label))

Mais ça crash.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
#0 0x4cfde9	odfaeg::core::FastDelegate<bool>::operator()<>() const(this=0x120d2c0) (/home/laurent/Développement/Projets-c++/ODFAEG/src/odfaeg/Core/../../../include/odfaeg/Core/fastDelegate.h:552)
#1 0x4cf334	odfaeg::core::Command::isTriggered(this=0x7ffff5adb7e0 <main_arena+128>) (/home/laurent/Développement/Projets-c++/ODFAEG/src/odfaeg/Core/command.cpp:43)
#2 0x4221c3	odfaeg::core::Listener::processEvents(this=0x10879b0) (/usr/local/include/odfaeg/Core/../Graphics/../Core/listener.h:122)
#3 0x453a15	odfaeg::graphic::RenderComponentManager::updateComponents(this=0x87a730) (/home/laurent/Développement/Projets-c++/ODFAEG/src/odfaeg/Graphics/renderComponentManager.cpp:99)
#4 0x42069c	odfaeg::core::Application::render(this=0x7fffffffe290) (/usr/local/include/odfaeg/Core/application.h:127)
#5 0x42011e	odfaeg::core::Application::exec(this=0x7fffffffe290) (/usr/local/include/odfaeg/Core/application.h:79)
#6 0x41ffe9	main(argc=1, argv=0x7fffffffe4d8) (/home/laurent/Développement/Projets-c++/ODFAEGCREATOR/main.cpp:4)
Alors je cherche une solution pour delete le foncteur à un autre endroit que dans le foncteur lui même.

Quelqu'un à t'il une idée ?

Merci d'avance.