diff options
author | Timothy Pearson <[email protected]> | 2013-05-03 15:58:35 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-05-03 15:58:35 -0500 |
commit | 670b8acba25ca1412a628cbf5d6460c197f92fc2 (patch) | |
tree | 2f887ee60964fdeffcb4575c2b4423bd00f3ca2f | |
parent | cfd528a3cb591ff6ed514ac7f38e12f9372ef9d6 (diff) | |
download | amarok-670b8acba25ca1412a628cbf5d6460c197f92fc2.tar.gz amarok-670b8acba25ca1412a628cbf5d6460c197f92fc2.zip |
Fix Amarok startup crashes
Fix a number of warnings and glitches
-rw-r--r-- | amarok/src/analyzers/blockanalyzer.cpp | 31 | ||||
-rw-r--r-- | amarok/src/analyzers/boomanalyzer.cpp | 13 | ||||
-rw-r--r-- | amarok/src/browserbar.cpp | 8 | ||||
-rw-r--r-- | amarok/src/collectiondb.cpp | 3 | ||||
-rw-r--r-- | amarok/src/collectionscanner/collectionscanner.cpp | 7 | ||||
-rw-r--r-- | amarok/src/contextbrowser.cpp | 9 | ||||
-rw-r--r-- | amarok/src/playlistloader.cpp | 2 | ||||
-rw-r--r-- | amarok/src/playlistloader.h | 2 | ||||
-rw-r--r-- | amarok/src/playlistwindow.cpp | 4 | ||||
-rw-r--r-- | amarok/src/starmanager.cpp | 13 | ||||
-rw-r--r-- | amarok/src/starmanager.h | 2 | ||||
-rw-r--r-- | amarok/src/systray.cpp | 26 | ||||
-rw-r--r-- | amarok/src/xmlloader.cpp | 5 | ||||
-rw-r--r-- | amarok/src/xmlloader.h | 2 |
14 files changed, 87 insertions, 40 deletions
diff --git a/amarok/src/analyzers/blockanalyzer.cpp b/amarok/src/analyzers/blockanalyzer.cpp index 666340af..444f1778 100644 --- a/amarok/src/analyzers/blockanalyzer.cpp +++ b/amarok/src/analyzers/blockanalyzer.cpp @@ -48,8 +48,9 @@ BlockAnalyzer::BlockAnalyzer( TQWidget *parent ) setMaximumWidth( MAX_COLUMNS*(WIDTH+1) -1 ); // mxcl says null pixmaps cause crashes, so let's play it safe - for ( uint i = 0; i < FADE_SIZE; ++i ) + for ( uint i = 0; i < FADE_SIZE; ++i ) { m_fade_bars[i].resize( 1, 1 ); + } } BlockAnalyzer::~BlockAnalyzer() @@ -80,23 +81,26 @@ BlockAnalyzer::resizeEvent( TQResizeEvent *e ) if( m_rows != oldRows ) { m_barPixmap.resize( WIDTH, m_rows*(HEIGHT+1) ); - for ( uint i = 0; i < FADE_SIZE; ++i ) + for ( uint i = 0; i < FADE_SIZE; ++i ) { m_fade_bars[i].resize( WIDTH, m_rows*(HEIGHT+1) ); + } m_yscale.resize( m_rows + 1 ); const uint PRE = 1, PRO = 1; //PRE and PRO allow us to restrict the range somewhat - for( uint z = 0; z < m_rows; ++z ) + for( uint z = 0; z < m_rows; ++z ) { m_yscale[z] = 1 - (log10( PRE+z ) / log10( PRE+m_rows+PRO )); + } m_yscale[m_rows] = 0; determineStep(); paletteChange( palette() ); } - else if( width() > e->oldSize().width() || height() > e->oldSize().height() ) + else if( width() > e->oldSize().width() || height() > e->oldSize().height() ) { drawBackground(); + } analyze( m_scope ); } @@ -148,18 +152,25 @@ BlockAnalyzer::analyze( const Analyzer::Scope &s ) // Paint the background bitBlt( canvas(), 0, 0, background() ); - for( uint y, x = 0; x < m_scope.size(); ++x ) + uint y; + for( uint x = 0; x < m_scope.size(); ++x ) { + if (m_yscale.size() < 1) { + return; + } + // determine y for( y = 0; m_scope[x] < m_yscale[y]; ++y ) ; // this is opposite to what you'd think, higher than y // means the bar is lower than y (physically) - if( (float)y > m_store[x] ) + if( (float)y > m_store[x] ) { y = int(m_store[x] += m_step); - else + } + else { m_store[x] = y; + } // if y is lower than m_fade_pos, then the bar has exceeded the height of the fadeout // if the fadeout is quite faded now, then display the new one @@ -174,15 +185,17 @@ BlockAnalyzer::analyze( const Analyzer::Scope &s ) bitBlt( canvas(), x*(WIDTH+1), y, &m_fade_bars[offset], 0, 0, WIDTH, height() - y ); } - if( m_fade_intensity[x] == 0 ) + if( m_fade_intensity[x] == 0 ) { m_fade_pos[x] = m_rows; + } //REMEMBER: y is a number from 0 to m_rows, 0 means all blocks are glowing, m_rows means none are bitBlt( canvas(), x*(WIDTH+1), y*(HEIGHT+1) + m_y, bar(), 0, y*(HEIGHT+1) ); } - for( uint x = 0; x < m_store.size(); ++x ) + for( uint x = 0; x < m_store.size(); ++x ) { bitBlt( canvas(), x*(WIDTH+1), int(m_store[x])*(HEIGHT+1) + m_y, &m_topBarPixmap ); + } } diff --git a/amarok/src/analyzers/boomanalyzer.cpp b/amarok/src/analyzers/boomanalyzer.cpp index 3505c82c..3f7f8223 100644 --- a/amarok/src/analyzers/boomanalyzer.cpp +++ b/amarok/src/analyzers/boomanalyzer.cpp @@ -71,7 +71,18 @@ BoomAnalyzer::init() { const double F = (double)y * h; - p.setPen( TQColor( 255 - int(229.0 * F), 255 - int(229.0 * F), 255 - int(191.0 * F) ) ); + int r = 255 - int(229.0 * F); + int g = 255 - int(229.0 * F); + int b = 255 - int(191.0 * F); + + if (r < 0) r = 0; + if (g < 0) g = 0; + if (b < 0) b = 0; + if (r > 255) r = 255; + if (g > 255) g = 255; + if (b > 255) b = 255; + + p.setPen( TQColor( r, g, b ) ); p.drawLine( 0, y, COLUMN_WIDTH-2, y ); } } diff --git a/amarok/src/browserbar.cpp b/amarok/src/browserbar.cpp index 1d3e8625..ef1babf4 100644 --- a/amarok/src/browserbar.cpp +++ b/amarok/src/browserbar.cpp @@ -94,9 +94,11 @@ BrowserBar::BrowserBar( TQWidget *parent ) m_tabBar->setFixedWidth( m_pos ); m_tabBar->move( 0, 25 ); - TQVBoxLayout *layout = new TQVBoxLayout( m_browserBox ); - layout->addSpacing( 3 ); // aesthetics - layout->setAutoAdd( true ); + if (m_browserBox && (!m_browserBox->layout())) { + TQVBoxLayout *layout = new TQVBoxLayout( m_browserBox ); + layout->addSpacing( 3 ); // aesthetics + layout->setAutoAdd( true ); + } m_browserBox->move( m_pos, 0 ); m_browserBox->hide(); diff --git a/amarok/src/collectiondb.cpp b/amarok/src/collectiondb.cpp index 24a79f9e..1761f7c1 100644 --- a/amarok/src/collectiondb.cpp +++ b/amarok/src/collectiondb.cpp @@ -224,6 +224,9 @@ CollectionDB::CollectionDB() , m_aftEnabledPersistentTables() , m_moveFileJobCancelled( false ) { + // We have our own thread manager + disableThreadPostedEvents(true); + DEBUG_BLOCK #ifdef USE_MYSQL diff --git a/amarok/src/collectionscanner/collectionscanner.cpp b/amarok/src/collectionscanner/collectionscanner.cpp index 8636410d..7dace13a 100644 --- a/amarok/src/collectionscanner/collectionscanner.cpp +++ b/amarok/src/collectionscanner/collectionscanner.cpp @@ -177,8 +177,9 @@ CollectionScanner::readDir( const TQString& dir, TQStringList& entries ) static DCOPRef dcopRef( "amarok", "collection" ); // linux specific, but this fits the 90% rule - if( dir.startsWith( "/dev" ) || dir.startsWith( "/sys" ) || dir.startsWith( "/proc" ) ) + if( dir.startsWith( "/dev" ) || dir.startsWith( "/sys" ) || dir.startsWith( "/proc" ) ) { return; + } const TQCString dir8Bit = TQFile::encodeName( dir ); DIR *d = opendir( dir8Bit ); @@ -213,7 +214,9 @@ CollectionScanner::readDir( const TQString& dir, TQStringList& entries ) f = i; break; } #else - f = m_processedDirs.find( de ); + if (m_processedDirs.count() > 0) { + f = m_processedDirs.find( de ); + } #endif if ( ! S_ISDIR( statBuf.st_mode ) || f != -1 ) { diff --git a/amarok/src/contextbrowser.cpp b/amarok/src/contextbrowser.cpp index 1d3ff5b5..7cdc0318 100644 --- a/amarok/src/contextbrowser.cpp +++ b/amarok/src/contextbrowser.cpp @@ -361,7 +361,7 @@ ContextBrowser::ContextBrowser( const char *name ) this, TQT_SLOT( tagsChanged( const TQString&, const TQString& ) ) ); connect( CollectionDB::instance(), TQT_SIGNAL( ratingChanged( const TQString&, int ) ), this, TQT_SLOT( ratingOrScoreOrLabelsChanged( const TQString& ) ) ); - connect( StarManager::instance(), TQT_SIGNAL( ratingsColorsChanged() ), + connect( StarManager::instance(), TQT_SIGNAL( ratingsColorsChanged( const TQString& ) ), this, TQT_SLOT( ratingOrScoreOrLabelsChanged( const TQString& ) ) ); connect( CollectionDB::instance(), TQT_SIGNAL( scoreChanged( const TQString&, float ) ), this, TQT_SLOT( ratingOrScoreOrLabelsChanged( const TQString& ) ) ); @@ -4352,11 +4352,12 @@ void ContextBrowser::ratingOrScoreOrLabelsChanged( const TQString &path ) //SLOT //have their ratings changed in the playlist won't be reflected until the context browser refreshes //which can be confusing, and looks less polished/professional //This can be changed if it slows things down too much... - if( m_browseLabels || ( currentTrack.isFile() && ( currentTrack.url().path() == path || AmarokConfig::useRatings() ) ) ) + if( m_browseLabels || ( currentTrack.isFile() && ( currentTrack.url().path() == path || AmarokConfig::useRatings() ) ) ) { m_dirtyCurrentTrackPage = true; // will be reloaded when viewed (much faster) - - if( currentPage() == m_contextTab ) + } + if( currentPage() == m_contextTab ) { refreshCurrentTrackPage(); + } } void ContextBrowser::tagsChanged( const MetaBundle &bundle ) //SLOT diff --git a/amarok/src/playlistloader.cpp b/amarok/src/playlistloader.cpp index aca4a223..0eebba0b 100644 --- a/amarok/src/playlistloader.cpp +++ b/amarok/src/playlistloader.cpp @@ -479,7 +479,7 @@ UrlLoader::loadXml( const KURL &url ) } } -void UrlLoader::slotNewBundle( const MetaBundle &bundle, const XmlAttributeList &atts ) +void UrlLoader::slotNewBundle( const MetaBundle& bundle, const XmlAttributeList& atts ) { XMLData data; data.bundle = TQDeepCopy<MetaBundle>( bundle ); diff --git a/amarok/src/playlistloader.h b/amarok/src/playlistloader.h index 07c2e3c6..357a9526 100644 --- a/amarok/src/playlistloader.h +++ b/amarok/src/playlistloader.h @@ -129,7 +129,7 @@ protected: void loadXml( const KURL& ); private slots: - void slotNewBundle( const MetaBundle &bundle, const XmlAttributeList &attributes ); + void slotNewBundle( const MetaBundle& bundle, const XmlAttributeList& attributes ); void slotPlaylistInfo( const TQString &product, const TQString &version, const TQString &dynamicMode ); private: diff --git a/amarok/src/playlistwindow.cpp b/amarok/src/playlistwindow.cpp index 677f73f3..c7f6c794 100644 --- a/amarok/src/playlistwindow.cpp +++ b/amarok/src/playlistwindow.cpp @@ -408,7 +408,7 @@ void PlaylistWindow::init() connect( m_settingsMenu, TQT_SIGNAL( activated(int) ), TQT_SLOT( slotMenuActivated(int) ) ); //END Settings menu - m_menubar->insertItem( i18n( "E&ngage" ), actionsMenu ); + m_menubar->insertItem( i18n( "&File" ), actionsMenu ); m_menubar->insertItem( i18n( "&Playlist" ), playlistMenu ); m_menubar->insertItem( i18n( "&Mode" ), modeMenu ); m_menubar->insertItem( i18n( "&Tools" ), m_toolsMenu ); @@ -419,7 +419,7 @@ void PlaylistWindow::init() TQBoxLayout *layV = new TQVBoxLayout( this ); layV->addWidget( m_menubar ); layV->addWidget( m_browsers, 1 ); - layV->addWidget( m_toolbar ); +// layV->addWidget( m_toolbar ); layV->addSpacing( 2 ); layV->addWidget( statusbar ); diff --git a/amarok/src/starmanager.cpp b/amarok/src/starmanager.cpp index d759ead4..adeb8665 100644 --- a/amarok/src/starmanager.cpp +++ b/amarok/src/starmanager.cpp @@ -54,10 +54,12 @@ StarManager::~StarManager() {} void StarManager::reinitStars( int height, int margin ) { - if( height != -1 ) + if( height != -1 ) { m_height = height; - if( margin != -1 ) + } + if( margin != -1 ) { m_margin = margin; + } int hval = m_height + m_margin * 2 - 4 + ( ( m_height % 2 ) ? 1 : 0 ); TQImage star = TQImage( locate( "data", "amarok/images/star.png" ) ).smoothScale( hval, hval, TQ_ScaleMin ); @@ -73,8 +75,9 @@ StarManager::reinitStars( int height, int margin ) TQImage fullHalf = TQImage( locate( "data", "amarok/images/smallstar.png" ) ); m_halfStar = half.copy(); m_fullHalfStar = fullHalf.copy(); - if( AmarokConfig::customRatingsColors() ) + if( AmarokConfig::customRatingsColors() ) { TDEIconEffect::colorize( m_halfStar, m_halfStarColor, 1.0 ); + } m_halfStarPix.convertFromImage( m_halfStar ); m_fullHalfStarPix.convertFromImage( m_fullHalfStar ); @@ -101,7 +104,9 @@ StarManager::reinitStars( int height, int margin ) if( CollectionView::instance() && CollectionView::instance()->viewMode() == CollectionView::modeFlatView ) CollectionView::instance()->triggerUpdate(); - emit ratingsColorsChanged(); + // FIXME + // Not ideal but should work sufficiently for now + emit ratingsColorsChanged(TQString::null); } TQPixmap* diff --git a/amarok/src/starmanager.h b/amarok/src/starmanager.h index acf2b5ce..ebcbdaf3 100644 --- a/amarok/src/starmanager.h +++ b/amarok/src/starmanager.h @@ -41,7 +41,7 @@ class StarManager : public TQObject void reinitStars( int height = -1, int margin = -1 ); signals: - void ratingsColorsChanged(); + void ratingsColorsChanged( const TQString &url ); private: diff --git a/amarok/src/systray.cpp b/amarok/src/systray.cpp index 69f07e2f..7c6721e6 100644 --- a/amarok/src/systray.cpp +++ b/amarok/src/systray.cpp @@ -105,7 +105,7 @@ Amarok::TrayIcon::event( TQEvent *e ) void Amarok::TrayIcon::resizeEvent ( TQResizeEvent * ) { // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes - baseIcon = KSystemTray::loadSizedIcon( "amarok", width() ); + baseIcon = KSystemTray::loadSizedIcon( "amarok", width() ); if (overlay == &pauseOverlay) { pauseOverlay = Amarok::loadOverlay( "pause", width() ); overlay = &pauseOverlay; @@ -187,12 +187,14 @@ Amarok::TrayIcon::paintIcon( int mergePixels, bool force ) { // skip redrawing the same pixmap static int mergePixelsCache = 0; - if ( mergePixels == mergePixelsCache && !force ) - return; + if ( mergePixels == mergePixelsCache && !force ) { + return; + } mergePixelsCache = mergePixels; - if ( mergePixels < 0 ) + if ( mergePixels < 0 ) { return blendOverlay( baseIcon ); + } // make up the grayed icon if ( grayedIcon.isNull() ) @@ -202,7 +204,7 @@ Amarok::TrayIcon::paintIcon( int mergePixels, bool force ) grayedIcon = tmpTrayIcon; } - // make up the alternate icon (use hilight color but more saturated) + // make up the alternate icon (use highlight color but more saturated) if ( alternateIcon.isNull() ) { TQImage tmpTrayIcon = baseIcon.convertToImage(); @@ -217,10 +219,12 @@ Amarok::TrayIcon::paintIcon( int mergePixels, bool force ) alternateIcon = tmpTrayIcon; } - if ( mergePixels >= alternateIcon.height() ) + if ( mergePixels >= alternateIcon.height() ) { return blendOverlay( grayedIcon ); - if ( mergePixels == 0 ) + } + if ( mergePixels == 0 ) { return blendOverlay( alternateIcon ); + } // mix [ grayed <-> colored ] icons TQPixmap tmpTrayPixmap = alternateIcon; @@ -232,8 +236,9 @@ Amarok::TrayIcon::paintIcon( int mergePixels, bool force ) void Amarok::TrayIcon::blendOverlay( TQPixmap &sourcePixmap ) { - if ( !overlayVisible || !overlay || overlay->isNull() ) + if ( !overlayVisible || !overlay || overlay->isNull() ) { return setPixmap( sourcePixmap ); // @since 3.2 + } // here comes the tricky part.. no tdefx functions are helping here.. :-( // we have to blend pixmaps with different sizes (blending will be done in @@ -248,9 +253,10 @@ Amarok::TrayIcon::blendOverlay( TQPixmap &sourcePixmap ) copyBlt( &sourceCropped, 0,0, &sourcePixmap, opX,opY, opW,opH ); //speculative fix for a bactrace we received - //crash was in covertToImage() somewhere in this function - if( sourceCropped.isNull() ) + //crash was in convertToImage() somewhere in this function + if( sourceCropped.isNull() ) { return setPixmap( sourcePixmap ); + } // blend the overlay image over the cropped rectangle TQImage blendedImage = sourceCropped.convertToImage(); diff --git a/amarok/src/xmlloader.cpp b/amarok/src/xmlloader.cpp index 2ff72b21..9328f23e 100644 --- a/amarok/src/xmlloader.cpp +++ b/amarok/src/xmlloader.cpp @@ -26,11 +26,14 @@ MetaBundle::XmlLoader::XmlLoader(): m_aborted( false ), m_target( 0 ) { + // We have our own thread manager + disableThreadPostedEvents(true); + m_reader.setContentHandler( this ); m_reader.setErrorHandler( this ); } -MetaBundle::XmlLoader::~XmlLoader() {} +MetaBundle::XmlLoader::~XmlLoader(){} bool MetaBundle::XmlLoader::load( TQXmlInputSource *source, TQObject *target ) { diff --git a/amarok/src/xmlloader.h b/amarok/src/xmlloader.h index bbbf681c..75bdf386 100644 --- a/amarok/src/xmlloader.h +++ b/amarok/src/xmlloader.h @@ -136,7 +136,7 @@ class MetaBundle::XmlLoader: public TQObject, public TQXmlDefaultHandler * @param bundle the loaded MetaBundle * @param extraAttributes any extra attributes in the XML not recognized */ - void newBundle( const MetaBundle &bundle, const XmlAttributeList &extraAttributes ); + void newBundle( const MetaBundle& bundle, const XmlAttributeList& extraAttributes ); /** Emitted when an error occurs. */ void error( const TQString &errorMessage ); |