From 3c508cad0032f46be56279f3a3ab5a7df9128bef Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 30 Dec 2010 14:47:12 +0100 Subject: Fix qWarnings() at startup and shutdown Fix unexpected NULL receiver on startup: Turns out this warning is issued when calling deleteLater on a NULL object. This happened in SheMov::createOpenWith*. The "database is still in use" warning was a bit harder to track down. First of all, the destructors weren't called since Qt::WA_DeleteOnClose wasn't set for SheMov, so Qt would simply exit and let the OS do the cleanup without calling the destructors. Then there were several orphan widgets/objects without a parent, so their destructor would never be called. --- shemov.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'shemov.cpp') diff --git a/shemov.cpp b/shemov.cpp index ccf773e..fbe4cb9 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -51,6 +51,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), mOpenWithGroupFS(0), mOpenWithGroupAV(0) { //application icon qApp->setWindowIcon(QIcon(":/shemov.png")); + setAttribute(Qt::WA_DeleteOnClose); //init database as early as possible (void) SmGlobals::instance(); @@ -768,8 +769,8 @@ void SheMov::createOpenWithMenuFS(){ foreach(QAction *a, mOpenWithGroupFS->actions()){ mOpenWithMenuFS->removeAction(a); } + mOpenWithGroupFS->deleteLater(); } - mOpenWithGroupFS->deleteLater(); mOpenWithGroupFS = new QActionGroup(this); QSettings s; QStringList moviePlayers = s.value("programs_movieviewer/data").toHash().keys(); @@ -798,9 +799,9 @@ void SheMov::createOpenWithMenuAV(){ foreach(QAction *a, mOpenWithGroupAV->actions()){ mOpenWithMenuAV->removeAction(a); } + //this deletes all actions in the group also! + mOpenWithGroupAV->deleteLater(); } - //this deletes all actions in the group also! - mOpenWithGroupAV->deleteLater(); mOpenWithGroupAV = new QActionGroup(this); QSettings s; QStringList players = s.value("programs_movieviewer/data").toHash().keys(); -- cgit v1.2.3-70-g09d2