Fix Amarok startup crashes

Fix a number of warnings and glitches
(cherry picked from commit 670b8acba2)
v3.5.13-sru
Timothy Pearson 11 years ago committed by Slávek Banko
parent d806197381
commit d2f156e185

@ -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 );
}
}

@ -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 );
}
}

@ -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();

@ -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 ) {

@ -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

@ -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 );

@ -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:

@ -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 );

@ -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() ) {
KIconEffect::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*

@ -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:

@ -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 kdefx 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();

@ -30,7 +30,7 @@ MetaBundle::XmlLoader::XmlLoader(): m_aborted( false ), m_target( 0 )
m_reader.setErrorHandler( this );
}
MetaBundle::XmlLoader::~XmlLoader() {}
MetaBundle::XmlLoader::~XmlLoader(){}
bool MetaBundle::XmlLoader::load( TQXmlInputSource *source, TQObject *target )
{

@ -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 );

Loading…
Cancel
Save