从C++打开文件对话框时,JNI内存泄漏



问题:单击openfiledialog时挂起

对了,当我在C++程序中单击openfiledialog按钮时,它会输入并询问我需要使用哪个文件,但现在我单击按钮时它就完全挂起了。

目前我有一个在C++中成功运行的C++程序。因此,我决定试用Java的JNI。我将C++程序导入到DLL中,成功地使用java命令执行C++程序。整个程序可以工作,只有一部分不工作,那就是openfiledialog。

我不知道为什么,但我坚信,当展示对话框就位时,这是记忆的一部分,有专家能解释一下吗?谢谢

显示对话框的C++代码。

private: System::Void btnOpen_Click(System::Object^  sender, System::EventArgs^  e) {
            vector<vector<int>> file;
            vector<int> column;
            int col = 0;
            int row = 0;
            openFileDialog->ShowDialog(); <- Does not even execute showdialog at all
            string test = msclr::interop::marshal_as<std::string>(openFileDialog->FileName); <-- I strongly suspect this part has an issue that causes the crash
            cout << test << endl;
file.open(test);
.... (does the normal appending of text into the vectors)
file.close(test);

我发现我导入的DLL没有添加到metagen中,也没有添加到相对文件夹中,这就是它导致错误的原因。

谢谢大家:)