author | zecke <zecke> | 2002-09-10 13:54:23 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-10 13:54:23 (UTC) |
commit | 4aad041a733e2478ff29330e1544e5fefcfb5cde (patch) (side-by-side diff) | |
tree | d45f21fa4570037b516ebfc1dd95aac56b3e6660 | |
parent | 9ae3234e770008c4fac9dc69ffc9bb0cb0f1b2ae (diff) | |
download | opie-4aad041a733e2478ff29330e1544e5fefcfb5cde.zip opie-4aad041a733e2478ff29330e1544e5fefcfb5cde.tar.gz opie-4aad041a733e2478ff29330e1544e5fefcfb5cde.tar.bz2 |
Fix floating point exception divide by 0 in qpedecoration
-rw-r--r-- | library/qpedecoration_qws.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index 222d906..c2eb751 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp @@ -1,238 +1,239 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifdef QWS #define QTOPIA_INTERNAL_LANGLIST #include <qapplication.h> #include <qstyle.h> #include <qwidget.h> #include <qpainter.h> #include <qtimer.h> #include <qwhatsthis.h> #include "qcopenvelope_qws.h" #include "qpedecoration_qws.h" #include <qdialog.h> #include <qdrawutil.h> #include <qgfx_qws.h> #include "qpeapplication.h" #include "resource.h" #include "global.h" #include "qlibrary.h" #include "windowdecorationinterface.h" #include <qfile.h> #include <qsignal.h> #include <stdlib.h> extern QRect qt_maxWindowRect; #define WHATSTHIS_MODE #ifndef QT_NO_QWS_QPE_WM_STYLE #ifndef QT_NO_IMAGEIO_XPM /* XPM */ static const char * const qpe_close_xpm[] = { "16 16 3 1", " c None", ". c #FFFFFF", "+ c #000000", " ", " ", " ..... ", " ..+++++.. ", " .+++++++++. ", " .+..+++..+. ", " .++...+...++. ", " .+++.....+++. ", " .++++...++++. ", " .+++.....+++. ", " .++...+...++. ", " .+..+++..+. ", " .+++++++++. ", " ..+++++.. ", " ..... ", " "}; /* XPM */ static const char * const qpe_accept_xpm[] = { "16 16 3 1", " c None", ". c #FFFFFF", "+ c #000000", " ", " ", " ..... ", " ..+++++.. ", " .+++++++++. ", " .+++++++++. ", " .+++++++..++. ", " .++.+++...++. ", " .+...+...+++. ", " .+......++++. ", " .++....+++++. ", " .++..+++++. ", " .+++++++++. ", " ..+++++.. ", " ..... ", " "}; #endif // QT_NO_IMAGEIO_XPM class HackWidget : public QWidget { public: bool needsOk() { return (getWState() & WState_Reserved1 ) || (inherits( "QDialog" ) && !inherits( "QMessageBox" ) ); } }; static QImage scaleButton( const QImage &img, int height ) { - if ( img.height() != height ) { + qWarning("Height %d %d", height, img.height() ); + if ( img.height()!=0 && img.height() != height ) { return img.smoothScale( img.width()*height/img.height(), height ); } else { return img; } } class TLWidget : public QWidget { public: QWSManager *manager() { return topData()->qwsManager; } QTLWExtra *topExtra() { return topData(); } void setWState( uint s ) { QWidget::setWState( s ); } void clearWState( uint s ) { QWidget::clearWState( s ); } }; QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) { wtTimer = new QTimer( this ); connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); } void QPEManager::updateActive() { QWidget *newActive = qApp->activeWindow(); if ( newActive && (QWidget*)active == newActive ) return; if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); } if ( newActive && ((TLWidget *)newActive)->manager() ) { active = newActive; ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); } else if ( !newActive ) { active = 0; } } int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) { QRect rect(w->geometry()); if ( decoration->region( w, rect, (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) return QPEDecoration::Help; for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) return (QWSDecoration::Region)i; } return QWSDecoration::None; } bool QPEManager::eventFilter( QObject *o, QEvent *e ) { QWSManager *mgr = (QWSManager *)o; QWidget *w = mgr->widget(); switch ( e->type() ) { case QEvent::MouseButtonPress: { pressTime = QTime::currentTime(); QPoint p = ((QMouseEvent*)e)->globalPos(); int inRegion = pointInQpeRegion( w, p ); #ifdef WHATSTHIS_MODE if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { QString text; switch ( inRegion ) { case QWSDecoration::Close: if ( ((HackWidget*)w)->needsOk() ) text = tr("Click to close this window, discarding changes."); else text = tr("Click to close this window."); break; case QWSDecoration::Minimize: text = tr("Click to close this window and apply changes."); break; case QWSDecoration::Maximize: if ( w->isMaximized() ) text = tr("Click to make this window moveable."); else text = tr("Click to make this window use all available screen area."); break; default: break; } QWhatsThis::leaveWhatsThisMode( text ); whatsThisTimeout(); helpState = 0; return true; } #endif if ( inRegion == QPEDecoration::Help ) { #ifdef WHATSTHIS_MODE wtTimer->start( 400, TRUE ); #endif helpState = QWSButton::Clicked|QWSButton::MouseOver; drawButton( w, QPEDecoration::Help, helpState ); return true; } } break; case QEvent::MouseButtonRelease: if ( helpState & QWSButton::Clicked ) { wtTimer->stop(); helpState = 0; drawButton( w, QPEDecoration::Help, helpState ); QPoint p = ((QMouseEvent*)e)->globalPos(); if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { decoration->help( w ); } return true; } break; case QEvent::MouseMove: if ( helpState & QWSButton::Clicked ) { |