Found double free isue
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 6m51s

This commit is contained in:
2024-12-16 12:40:11 -05:00
parent 20b6f1041f
commit 780fd8308a
2 changed files with 29 additions and 7 deletions

View File

@@ -26,9 +26,9 @@ class MyWindow : public ReWindow::RWindow {
void OnKeyDown(const ReWindow::KeyDownEvent& e) override {}
void OnRefresh(float elapsed) override {
glClearColor(255, 0, 0, 255);
glClear(GL_COLOR_BUFFER_BIT);
GLSwapBuffers();
//glClearColor(255, 0, 0, 255);
//glClear(GL_COLOR_BUFFER_BIT);
//GLSwapBuffers();
auto pos = GetMouseCoordinates();
//std::cout << pos.x << ", " << pos.y << std::endl;
@@ -54,9 +54,9 @@ class MyWindow : public ReWindow::RWindow {
std::cout << "Mouse5 Mouse Button" << std::endl;
if (IsKeyDown(Keys::N))
if (IsKeyDown(Keys::N)) {
std::cout << "Gotteem" << std::endl;
}
RWindow::OnRefresh(elapsed);
}
@@ -153,7 +153,9 @@ int main() {
window->ManagedRefresh();
}
delete window;
// Found problem
// free(): double free detected in tcache 2
// delete window;
// Alternatively:
/*
* while (window->IsAlive()) {
@@ -170,6 +172,17 @@ int main() {
*/
//exit(0);
auto* windowdos = new MyWindow("Test Window Dos", 600, 480);
windowdos->SetRenderer(ReWindow::RenderingAPI::OPENGL);
windowdos->Open();
while (!windowdos->IsClosing()) {
//window->PollEvents();
windowdos->ManagedRefresh();
}
return 0;
}

View File

@@ -74,7 +74,7 @@ RWindowImpl::RWindowImpl(const std::string &wTitle, int wWidth, int wHeight, Ren
}
RWindowImpl::~RWindowImpl() {
if (pPlatform) { delete pPlatform; };
if (pPlatform) { std::cout << "FUCK" << std::endl; delete pPlatform; };
if (open)
DestroyOSWindowHandle();
}
@@ -162,12 +162,21 @@ void RWindowImpl::PollEvents() {
while(XPending(pPlatform->display)) {
XNextEvent(pPlatform->display, &pPlatform->xev);
if (pPlatform->xev.type == ClientMessage)
Logger::Info(std::format("Event '{}'", "ClientMessage"));
// Hmm
/*
if (pPlatform->xev.xclient.message_type == XInternAtom(pPlatform->display, "WM_PROTOCOLS", False) && static_cast<Atom>(pPlatform->xev.xclient.data.l[0]) == pPlatform->wmDeleteWindow) {
Close();
}
*/
if (pPlatform->xev.xclient.message_type == XInternAtom(pPlatform->display, "WM_PROTOCOLS", False)) {
Logger::Info("Closing");
Close();
}
if (pPlatform->xev.type == FocusIn) {
Logger::Debug(std::format("Event'{}'", "FocusIn"));