Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7188363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:04:04+00:00 2026-05-28T19:04:04+00:00

My program keeps crashing when I close the frame. I’ve narrowed the cause down

  • 0

My program keeps crashing when I close the frame. I’ve narrowed the cause down to two lines of problematic code, but I’m not sure why they’re crashing. Here’s some of my code:
TetrisFrame.cpp

TetrisFrame::TetrisFrame()
    : wxFrame(0, wxID_ANY, "Tetris")
{
    statusController_ = new StatusController;
    statusController_->setModel(new Statuses);
    statusController_->addView(this);

    tetrisController_ = new TetrisController;
    tetrisController_->setStatusController(statusController_.get());  // Problem one
    tetrisController_->setModel(new TetrisModel);
    tetrisController_->addView(new Board(this));  // Problem two
}

TetrisFrame class private member variables:

wxSharedPtr<StatusController> statusController_;
wxSharedPtr<TetrisController> tetrisController_;

StatusController class private section:

typedef wxSharedPtr<TetrisFrame> ViewPtr;
wxSharedPtr<Statuses> model_;
std::vector<ViewPtr> views_;

Board class private member variables:

wxSharedPtr<TetrisController> controller_;

relevant TetrisController functions:

void TetrisController::setStatusController(
        StatusController* statusControllerPtr)
{
    statusController_ = statusControllerPtr;
}

void TetrisController::addView(Board* viewPtr)
{
    views_.push_back(ViewPtr(viewPtr));
    viewPtr->setControlller(this);
}

Oddly enough problem two wasn’t crashing the program until I fixed another problem that was crashing the program. What’s wrong with my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:04:05+00:00Added an answer on May 28, 2026 at 7:04 pm

    Keep in mind that wxWidgets does its own form of memory management for widgets. So if you are dynamically allocating the memory for a widget-type, and you then pass the address of that widget to an object that can call delete on it while the parent of that widget is designated by the wxWidgets run-time to destroy that widget when the parent widget is destroyed, then you’re going to run into a case of double-deletion, or a case where the parent still thinks the child widget is a valid object when it’s not. A shared-pointer type will basically “own” an object … so make sure that when you dynamically allocate an object and pass it to a shared-pointer type that you are not inadvertently making the pointer “owned” by two different memory-reclaiming pathways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program keeps crashing, but the logcat does not show any exceptions. I just
I keep getting a -> Program received signal: EXC_BAD_ACCESS. In the following code but
The following program keeps crashing and I can't figure out what's wrong. It seems
I have a problem with my code. It keeps on crashing when i have
The Program keeps crashing when i try to run it on my handset. cant
I'm almost done with this program, but something's not right in main . Here
I'm trying to make a simple paint program in C#, but it keeps flickering
I programmed the following into Eclipse but the program keeps giving me the error:
Say I make a program that keeps track of the days I worked and
I'm writing a C program but I keep having problems with my array of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.