Author: kmachalkova Date: Mon May 26 17:47:16 2008 New Revision: 47882 URL: http://svn.opensuse.org/viewcvs/yast?rev=47882&view=rev Log: Creating dialogs on the stack is evil. Create pop-up dialog on demand only (#384467) Modified: trunk/ncurses-pkg/src/NCPackageSelector.cc trunk/ncurses-pkg/src/NCPackageSelector.h trunk/ncurses-pkg/src/NCPkgMenuExtras.cc trunk/ncurses-pkg/src/NCPkgPopupDiskspace.cc trunk/ncurses-pkg/src/NCPkgPopupDiskspace.h Modified: trunk/ncurses-pkg/src/NCPackageSelector.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPackageSelector.cc?rev=47882&r1=47881&r2=47882&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPackageSelector.cc (original) +++ trunk/ncurses-pkg/src/NCPackageSelector.cc Mon May 26 17:47:16 2008 @@ -162,7 +162,7 @@ depsPopup = new NCPkgPopupDeps( wpos( 3, 8 ), this ); // the disk space popup - diskspacePopup = new NCPkgPopupDiskspace( wpos( (NCurses::lines() - 15)/2, NCurses::cols()/6 ), testMode ); + diskspacePopup = new NCPkgDiskspace( testMode ); } Modified: trunk/ncurses-pkg/src/NCPackageSelector.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPackageSelector.h?rev=47882&r1=47881&r2=47882&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPackageSelector.h (original) +++ trunk/ncurses-pkg/src/NCPackageSelector.h Mon May 26 17:47:16 2008 @@ -55,7 +55,7 @@ class NCPkgRepoTable; class LangCode; class NCPkgPopupDeps; -class NCPkgPopupDiskspace; +class NCPkgDiskspace; class NCPkgFilterRPMGroups; class NCPkgFilterSearch; class NCPkgPopupFile; @@ -111,7 +111,7 @@ NCPkgLocaleTable * languagePopup; // language popup NCPkgRepoTable * repoPopup; - NCPkgPopupDiskspace * diskspacePopup; // the popup showing the disk usage + NCPkgDiskspace * diskspacePopup; // the popup showing the disk usage NCPkgFilterSearch * searchPopup; // the package search popup @@ -214,7 +214,7 @@ // returns the package table widget NCPkgTable * PackageList(); NCPkgPopupDeps *DepsPopup() { return depsPopup; } - NCPkgPopupDiskspace *diskSpacePopup() { return diskspacePopup; } + NCPkgDiskspace *diskSpacePopup() { return diskspacePopup; } YLabel *PackageLabel() { return packageLabel; } YLabel *PatternLabel() { return patternLabel; } Modified: trunk/ncurses-pkg/src/NCPkgMenuExtras.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgMenuExtras.cc?rev=47882&r1=47881&r2=47882&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPkgMenuExtras.cc (original) +++ trunk/ncurses-pkg/src/NCPkgMenuExtras.cc Mon May 26 17:47:16 2008 @@ -301,8 +301,7 @@ bool NCPkgMenuExtras::showDiskSpace() { - pkg->diskSpacePopup()->showInfoPopup( NCPkgStrings::DiskspaceLabel() ); - YDialog::deleteTopmostDialog(); + pkg->diskSpacePopup()->showInfoPopup( NCPkgStrings::DiskspaceLabel() ); //FIXME: move focus back to pkg table? return true; Modified: trunk/ncurses-pkg/src/NCPkgPopupDiskspace.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgPopupDiskspace.cc?rev=47882&r1=47881&r2=47882&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPkgPopupDiskspace.cc (original) +++ trunk/ncurses-pkg/src/NCPkgPopupDiskspace.cc Mon May 26 17:47:16 2008 @@ -60,13 +60,10 @@ // // DESCRIPTION : // -NCPkgPopupDiskspace::NCPkgPopupDiskspace( const wpos at, bool testMode ) - : NCPopup( at, false ) - , partitions( 0 ) - , okButton( 0 ) - , testmode( testMode ) +NCPkgDiskspace::NCPkgDiskspace( bool testMode ) + : testmode( testMode ) + , popupWin( 0 ) { - createLayout( ); if ( testMode ) { @@ -84,38 +81,8 @@ // // DESCRIPTION : // -NCPkgPopupDiskspace::~NCPkgPopupDiskspace() -{ -} - -/////////////////////////////////////////////////////////////////// -// -// -// METHOD NAME : NCPkgPopupDiskspace::createLayout -// METHOD TYPE : void -// -// DESCRIPTION : -// -void NCPkgPopupDiskspace::createLayout( ) +NCPkgDiskspace::~NCPkgDiskspace() { - // the vertical split is the (only) child of the dialog - NCLayoutBox * split = new NCLayoutBox( this, YD_VERT ); - - head = new NCLabel( split, "", true, false ); // isHeading = true - - YTableHeader * tableHeader = new YTableHeader(); - tableHeader->addColumn( NCPkgStrings::Partition(), YAlignBegin ); - tableHeader->addColumn( NCPkgStrings::UsedSpace(), YAlignBegin ); - tableHeader->addColumn( NCPkgStrings::FreeSpace(), YAlignBegin ); - tableHeader->addColumn( NCPkgStrings::TotalSpace(), YAlignBegin ); - tableHeader->addColumn( "% ", YAlignBegin ); - - // add the partition table - partitions = new NCTable( split, tableHeader ); - - // add the ok button - okButton = new NCPushButton( split, NCPkgStrings::OKLabel() ); - okButton->setFunctionKey( 10 ); } /////////////////////////////////////////////////////////////////// @@ -126,8 +93,9 @@ // // DESCRIPTION : // -void NCPkgPopupDiskspace::fillPartitionTable() +void NCPkgDiskspace::fillPartitionTable() { + NCTable * partitions = popupWin->Partitions(); partitions->deleteAllItems(); // clear table YTableItem * newItem; @@ -179,7 +147,7 @@ // // DESCRIPTION : // -string NCPkgPopupDiskspace::checkDiskSpace() +string NCPkgDiskspace::checkDiskSpace() { string text = ""; @@ -219,7 +187,7 @@ return text; } -void NCPkgPopupDiskspace::checkRemainingDiskSpace( const ZyppPartitionDu & partition ) +void NCPkgDiskspace::checkRemainingDiskSpace( const ZyppPartitionDu & partition ) { FSize usedSize ( partition.pkg_size, FSize::K ); FSize totalSize ( partition.total_size, FSize::K ); @@ -282,7 +250,7 @@ // DESCRIPTION : for testing only; called from PackageSelector // if running in testMode // -void NCPkgPopupDiskspace::setDiskSpace( wint_t ch ) +void NCPkgDiskspace::setDiskSpace( wint_t ch ) { int percent = 0; @@ -319,7 +287,7 @@ // // DESCRIPTION : // -void NCPkgPopupDiskspace::checkDiskSpaceRange( ) +void NCPkgDiskspace::checkDiskSpaceRange( ) { // see YQPkgDiskUsageList::updateDiskUsage() runningOutWarning.clear(); @@ -362,7 +330,7 @@ } -string NCPkgPopupDiskspace::usedPercent( FSize used, FSize total ) +string NCPkgDiskspace::usedPercent( FSize used, FSize total ) { int percent = 0; char percentStr[10]; @@ -383,23 +351,54 @@ // // DESCRIPTION : // -void NCPkgPopupDiskspace::showInfoPopup( string headline ) +void NCPkgDiskspace::showInfoPopup( string headline ) { - if ( head ) - head->setLabel( headline ); + popupWin = new NCPkgPopupDiskspace (wpos( (NCurses::lines() - 15)/2, NCurses::cols()/6 ), headline ); // update values in partition table fillPartitionTable(); - - postevent = NCursesEvent(); - do { - // show the popup - popupDialog( ); - } while ( postAgain() ); - - popdownDialog(); + popupWin->doit(); + YDialog::deleteTopmostDialog(); + } + + +NCPkgPopupDiskspace::NCPkgPopupDiskspace( const wpos at, string headline ) + : NCPopup( at, false ) + , partitions( 0 ) + , okButton( 0 ) + , head( 0 ) +{ + createLayout( headline ); +} + +NCPkgPopupDiskspace::~NCPkgPopupDiskspace() +{ } +void NCPkgPopupDiskspace::createLayout( string headline ) +{ + // the vertical split is the (only) child of the dialog + NCLayoutBox * split = new NCLayoutBox( this, YD_VERT ); + + head = new NCLabel( split, "", true, false ); // isHeading = true + head->setLabel( headline ); + + YTableHeader * tableHeader = new YTableHeader(); + tableHeader->addColumn( NCPkgStrings::Partition(), YAlignBegin ); + tableHeader->addColumn( NCPkgStrings::UsedSpace(), YAlignBegin ); + tableHeader->addColumn( NCPkgStrings::FreeSpace(), YAlignBegin ); + tableHeader->addColumn( NCPkgStrings::TotalSpace(), YAlignBegin ); + tableHeader->addColumn( "% ", YAlignBegin ); + + // add the partition table + partitions = new NCTable( split, tableHeader ); + + // add the ok button + okButton = new NCPushButton( split, NCPkgStrings::OKLabel() ); + okButton->setFunctionKey( 10 ); +} + + /////////////////////////////////////////////////////////////////// // // @@ -425,6 +424,17 @@ return NCurses::lines()-4; } +void NCPkgPopupDiskspace::doit() +{ + postevent = NCursesEvent(); + do { + // show the popup + popupDialog( ); + } while ( postAgain() ); + + popdownDialog(); + +} /////////////////////////////////////////////////////////////////// // // Modified: trunk/ncurses-pkg/src/NCPkgPopupDiskspace.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgPopupDiskspace.h?rev=47882&r1=47881&r2=47882&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPkgPopupDiskspace.h (original) +++ trunk/ncurses-pkg/src/NCPkgPopupDiskspace.h Mon May 26 17:47:16 2008 @@ -132,6 +132,33 @@ bool _warningPosted; }; +class NCPkgPopupDiskspace : public NCPopup { + +private: + NCTable * partitions; + NCPushButton * okButton; + NCLabel * head; + +protected: + + virtual bool postAgain(); + + virtual NCursesEvent wHandleInput( wint_t ch ); + +public: + NCPkgPopupDiskspace( const wpos at, string headline ); + + virtual ~NCPkgPopupDiskspace(); + + void createLayout( string headline ); + void doit(); + + NCTable *Partitions() { return partitions; } + + virtual int preferredWidth(); + virtual int preferredHeight(); + +}; /////////////////////////////////////////////////////////////////// // @@ -139,17 +166,15 @@ // // DESCRIPTION : // -class NCPkgPopupDiskspace : public NCPopup { +class NCPkgDiskspace { - NCPkgPopupDiskspace & operator=( const NCPkgPopupDiskspace & ); - NCPkgPopupDiskspace ( const NCPkgPopupDiskspace & ); + NCPkgDiskspace & operator=( const NCPkgDiskspace & ); + NCPkgDiskspace ( const NCPkgDiskspace & ); private: - NCTable * partitions; - NCPushButton * okButton; - NCLabel * head; bool testmode; + NCPkgPopupDiskspace *popupWin; ZyppDuSet testDiskUsage; string usedPercent( FSize used, FSize total ); @@ -164,20 +189,13 @@ **/ NCPkgWarningRangeNotifier overflowWarning; -protected: - - virtual bool postAgain(); - - virtual NCursesEvent wHandleInput( wint_t ch ); - + public: - NCPkgPopupDiskspace( const wpos at, bool testSpaceMode ); + NCPkgDiskspace( bool testSpaceMode ); - virtual ~NCPkgPopupDiskspace(); + virtual ~NCPkgDiskspace(); - virtual int preferredWidth(); - virtual int preferredHeight(); void fillPartitionTable(); @@ -187,17 +205,12 @@ void checkDiskSpaceRange( ); - void createLayout( ); - void showInfoPopup( string headline ); - + void checkRemainingDiskSpace( const ZyppPartitionDu & partition ); }; - - - /////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org