From kde-commits Fri Feb 25 12:26:43 2011 From: Alexey Khudyakov Date: Fri, 25 Feb 2011 12:26:43 +0000 To: kde-commits Subject: KDE/kdeedu/kstars/kstars/tools Message-Id: <20110225122643.C2F17AC8C0 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129863685625507 SVN commit 1222700 by khudyakov: Use QPointer to show dialog window. And avoid unnessesary ifs altogether M +2 -8 skycalendar.cpp --- trunk/KDE/kdeedu/kstars/kstars/tools/skycalendar.cpp #1222699:1222700 @@ -225,7 +225,6 @@ QPrinter printer; // Our printer object QString str_legend; // Text legend QString str_year; // Calendar's year - bool ok( false ); // True if the user click "Print" button in print dialog int text_height = 200; // Height of legend text zone in points QSize calendar_size; // Initial calendar widget size QFont calendar_font; // Initial calendar font @@ -235,15 +234,9 @@ printer.setResolution( 300 ); // Open print dialog - QPrintDialog *dialog = KdePrint::createPrintDialog( &printer, this ); + QPointer dialog( KdePrint::createPrintDialog( &printer, this ) ); dialog->setWindowTitle( i18n( "Print sky calendar" ) ); if ( dialog->exec() == QDialog::Accepted ) { - ok = true; - } - delete dialog; - - // If the user click on "Print" button - if ( ok ) { // Change mouse cursor QApplication::setOverrideCursor( Qt::WaitCursor ); @@ -293,6 +286,7 @@ // Restore mouse cursor QApplication::restoreOverrideCursor(); } + delete dialog; } void SkyCalendar::slotLocation() {