From 6f864ed3fcbc4ff0372fd66973ff1fa89b769fc3 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 2 Aug 2010 16:30:24 +0000 Subject: [PATCH] (trunk qt) #2050 "properties dialog changes seem to undo themselves" -- better fix --- qt/my-valgrind.sh | 2 +- qt/prefs-dialog.cc | 28 +++++++++++++++++----------- qt/prefs-dialog.h | 3 ++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/qt/my-valgrind.sh b/qt/my-valgrind.sh index d7d45db3d..c75201238 100755 --- a/qt/my-valgrind.sh +++ b/qt/my-valgrind.sh @@ -2,4 +2,4 @@ export G_SLICE=always-malloc export G_DEBUG=gc-friendly export GLIBCXX_FORCE_NEW=1 -valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=64 --log-file=x-valgrind --show-reachable=yes ./qtr +valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=32 --log-file=x-valgrind --show-reachable=yes ./transmission-qt diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index b715626fe..6d5b09cf1 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -57,7 +57,7 @@ void PrefsDialog :: checkBoxToggled( bool checked ) { const int key( sender( )->property( PREF_KEY ).toInt( ) ); - myPrefs.set( key, checked ); + setPref( key, checked ); } QCheckBox * @@ -86,9 +86,9 @@ PrefsDialog :: spinBoxChangedIdle( ) const QDoubleSpinBox * d = qobject_cast( spin ); if( d != 0 ) - myPrefs.set( key, d->value( ) ); + setPref( key, d->value( ) ); else - myPrefs.set( key, qobject_cast(spin)->value( ) ); + setPref( key, qobject_cast(spin)->value( ) ); } void @@ -152,7 +152,7 @@ PrefsDialog :: timeChanged( const QTime& time ) { const int key( sender()->property( PREF_KEY ).toInt( ) ); const int seconds( QTime().secsTo( time ) ); - myPrefs.set( key, seconds / 60 ); + setPref( key, seconds / 60 ); } QTimeEdit* @@ -172,7 +172,7 @@ void PrefsDialog :: textChanged( const QString& text ) { const int key( sender()->property( PREF_KEY ).toInt( ) ); - myPrefs.set( key, text ); + setPref( key, text ); } QLineEdit* @@ -255,7 +255,7 @@ void PrefsDialog :: altSpeedDaysEdited( int i ) { const int value = qobject_cast(sender())->itemData(i).toInt(); - myPrefs.set( Prefs::ALT_SPEED_LIMIT_TIME_DAY, value ); + setPref( Prefs::ALT_SPEED_LIMIT_TIME_DAY, value ); } @@ -458,7 +458,7 @@ void PrefsDialog :: encryptionEdited( int i ) { const int value( qobject_cast(sender())->itemData(i).toInt( ) ); - myPrefs.set( Prefs::ENCRYPTION, value ); + setPref( Prefs::ENCRYPTION, value ); } QWidget * @@ -552,8 +552,7 @@ PrefsDialog :: onDestinationClicked( void ) void PrefsDialog :: onLocationSelected( const QString& path, int key ) { - myPrefs.set( key, path ); - updatePref( key ); + setPref( key, path ); } QWidget * @@ -668,7 +667,7 @@ PrefsDialog :: PrefsDialog( Session& session, Prefs& prefs, QWidget * parent ): << Prefs :: INCOMPLETE_DIR << Prefs :: INCOMPLETE_DIR_ENABLED; foreach( int key, keys ) - updatePref( key ); + refreshPref( key ); // if it's a remote session, disable the preferences // that don't work in remote sessions @@ -684,6 +683,13 @@ PrefsDialog :: ~PrefsDialog( ) { } +void +PrefsDialog :: setPref( int key, const QVariant& v ) +{ + myPrefs.set( key, v ); + refreshPref( key ); +} + /*** **** ***/ @@ -706,7 +712,7 @@ PrefsDialog :: updateBlocklistCheckBox( ) } void -PrefsDialog :: updatePref( int key ) +PrefsDialog :: refreshPref( int key ) { switch( key ) { diff --git a/qt/prefs-dialog.h b/qt/prefs-dialog.h index 394b47cbc..2dc212f61 100644 --- a/qt/prefs-dialog.h +++ b/qt/prefs-dialog.h @@ -46,7 +46,7 @@ class PrefsDialog: public QDialog void spinBoxChangedIdle( ); void timeChanged( const QTime& ); void textChanged( const QString& ); - void updatePref( int key ); + void refreshPref( int key ); void encryptionEdited( int ); void altSpeedDaysEdited( int ); void sessionUpdated( ); @@ -77,6 +77,7 @@ class PrefsDialog: public QDialog ~PrefsDialog( ); private: + void setPref( int key, const QVariant& v ); bool isAllowed( int key ) const; QWidget * createTorrentsTab( ); QWidget * createSpeedTab( );