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 6892609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:33:23+00:00 2026-05-27T06:33:23+00:00

I have a logging interface that allows user to subclass a Logger and override

  • 0

I have a logging interface that allows user to subclass a Logger and override the log() virtual function so users can create their own loggers. There is a manager that keeps track of all the registered logging methods (i.e. Console, syslog, Widget, etc.)

I’ve created a QListWidget Logger that shows logs. Unfortunately it’s owned by the logging manager and since it’s a QObject, it’s also a child of the MainWindow. This results in two objects trying to delete it upon aplication close.

The first time around the QObjects->deleteChildren() gets called and it deletes it. Then the Loggin gmanager tries again and CRASH.

How can I prevent a specific QObject from being destroyed during deleteChildren()? Is that a bad idea?

  • 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-27T06:33:24+00:00Added an answer on May 27, 2026 at 6:33 am

    You can’t exclude a child from deletion, and if you could, that’d be a bad idea. In the QObject hierarchy, the child is owned by the parent. That’s one of the main purposes of the parent-child relationship. I don’t see why you should want a parent-child relationship without the deletion.

    Possibilities:

    1. Make it a child of the logging manager
    2. Don’t give it a parent at all and let the logging manager delete it
    3. Don’t give it a parent at all and use QSharedPointer/std::shared_ptr (the latter in C++11), managing it by using QSharedPointer instances int mainwindow and logger.

    Without knowing the code, I’d say the mainwindow shouldn’t mess with the logger, so I would move the ownership completely to the manager.

    Also, I don’t see a reason why the usual Logger interface should inherit from QObject at all, so I’d consider removing that inheritance completely (which leaves the “owned solely by Logging manager” and QSharedPointer options).

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

Sidebar

Related Questions

I have a static logging function that uses StringBuilder to concatenate a bunch of
I have an interface that I want Hibernate to log everything to. My curernt
Imagine I have a bunch of classes, that can do logging, so I've created
I have a little logging app (written in wxPython) that receives data from a
We have lots of logging calls in our app. Our logger takes a System.Type
I use SQL Server 2005. I have a simple logging table that my web
I have an interface for logging the exceptions, i.e. IExceptionLogger . This interface has
I'm working on a case logging system. Each case can have comments attached, so
I am trying to implement a logging factory and I have used an interface
I currently have a custom log manager that internally uses java.util.Formatter . The main

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.