author | erik <erik> | 2007-01-24 19:54:07 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 19:54:07 (UTC) |
commit | 89e81059e832ff77c2f0ac8b9db12f80eafa03fc (patch) (side-by-side diff) | |
tree | 99a130fc643d2aeefdecab452f644e7b61a5f50e | |
parent | 035bbc5bf689839c8d8e7be37f347b0dd900fccf (diff) | |
download | opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.zip opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.gz opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.bz2 |
Each file in this commit has an instance where a pointer is checked at
one point in the code and then not checked in another point in the code.
If it needed to be checked once, it needs to be checked the other time. If not
the application could segfault.
-rw-r--r-- | libopie2/opieui/big-screen/osplitter.cpp | 2 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 6 | ||||
-rw-r--r-- | noncore/applets/pcmcia/pcmcia.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/procctl.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.cpp | 63 | ||||
-rw-r--r-- | noncore/settings/sysinfo/devicesinfo.cpp | 2 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/http.c | 2 |
8 files changed, 48 insertions, 39 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp index 78e919a..5d1e2cf 100644 --- a/libopie2/opieui/big-screen/osplitter.cpp +++ b/libopie2/opieui/big-screen/osplitter.cpp @@ -134,193 +134,193 @@ QString OSplitter::label()const /** * This function sets the size change policy of the splitter. * If this size marked is crossed the splitter will relayout. * Note: that depending on the set Orientation it'll either look * at the width or height. * Note: If you want to from side to side view to tabbed view you need * to make sure that the size you supply is not smaller than the minimum * size of your added widgets. Note that if you use widgets like QComboBoxes * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy * * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. * @return void */ void OSplitter::setSizeChange( int width_height ) { m_size_policy = width_height; QSize sz(width(), height() ); QResizeEvent ev(sz, sz ); resizeEvent(&ev); } /** * This functions allows to add another OSplitter and to share * the OTabBar in small screen mode. The ownerships gets transfered. * OSplitters are always added after normal widget items */ void OSplitter::addWidget( OSplitter* split ) { m_splitter.append( split ); /* * set tab widget */ if (m_tabWidget ) setTabWidget( m_parentTab ); else { OSplitterContainer con; con.widget =split; addToBox( con ); } } /* * If in a tab it should be removed * and if in a hbox the reparent kills it too */ /** * This removes the splitter again. You currently need to call this * before you delete or otherwise you can get mem corruption * or other weird behaviour. * Owner ship gets transfered back to you it's current parent * is 0 */ void OSplitter::removeWidget( OSplitter* split) { split->setTabWidget( 0 ); split->reparent( 0, 0, QPoint(0, 0) ); } /** * Adds a widget to the Splitter. The widgets gets inserted * at the end of either the Box or TabWidget. * Ownership gets transfered and the widgets gets reparented. * Note: icon and label is only available on small screensizes * if size is smaller than the mark * Warning: No null checking of the widget is done. Only on debug * a message will be outputtet * * @param wid The widget which will be added * @param icon The icon of the possible Tab * @param label The label of the possible Tab */ void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) { #ifdef DEBUG if (!wid ) return; #endif OSplitterContainer cont; cont.widget = wid; cont.icon =icon; cont.name = label; m_container.append( cont ); /* * */ if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) setTabWidget( m_parentTab ); else { if (m_hbox ) addToBox( cont ); - else + else if (m_tabWidget) addToTab( cont ); } } /** * Removes the widget from the tab widgets if necessary. * OSplitter drops ownership of this widget and the widget * will be reparented i tto 0. * The widget will not be deleted. * * @param w The widget to be removed */ void OSplitter::removeWidget( QWidget* w) { ContainerList::Iterator it; for ( it = m_container.begin(); it != m_container.end(); ++it ) if ( (*it).widget == w ) break; if (it == m_container.end() ) return; /* only tab needs to be removed.. box recognizes it */ if ( !m_hbox ) removeFromTab( w ); /* Find reparent it and remove it from our list */ w->reparent( 0, 0, QPoint(0, 0)); it = m_container.remove( it ); } /** * This method will give focus to the widget. If in a tabwidget * the tabbar will be changed * * @param w The widget which will be set the current one */ void OSplitter::setCurrentWidget( QWidget* w) { if (m_tabWidget ) m_tabWidget->setCurrentTab( w ); // else // m_hbox->setFocus( w ); } /** * This is an overloaded member function and only differs in the * argument it takes. * Searches list of widgets for label. It'll pick the first label it finds * * @param label Label to look for. First match will be taken */ void OSplitter::setCurrentWidget( const QString& label ) { ContainerList::Iterator it; for (it = m_container.begin(); it != m_container.end(); ++it ) { if ( (*it).name == label ) { setCurrentWidget( (*it).widget ); break; } } } /** * This will only work when the TabWidget is active * If everything is visible this signal is kindly ignored * @see OTabWidget::setCurrentTab(int) * * @param tab The tab to make current */ void OSplitter::setCurrentWidget( int tab ) { if (m_tabWidget ) m_tabWidget->setCurrentTab( tab ); } /** * return the currently activated widget if in tab widget mode * or null because all widgets are visible */ QWidget* OSplitter::currentWidget() const { if (m_tabWidget) return m_tabWidget->currentWidget(); else if (m_parentTab ) return m_parentTab->currentWidget(); diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 34f5e6a..d959c7a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp @@ -1676,199 +1676,199 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) quit(); } else if ( msg == "close()" ) { hideOrQuit(); } else if ( msg == "disablePreload()" ) { d->preloaded = FALSE; d->keep_running = TRUE; /* so that quit will quit */ } else if ( msg == "enablePreload()" ) { if (d->qpe_main_widget) d->preloaded = TRUE; d->keep_running = TRUE; /* so next quit won't quit */ } else if ( msg == "raise()" ) { d->keep_running = TRUE; d->notbusysent = FALSE; raiseAppropriateWindow(); // Tell the system we're still chugging along... QCopEnvelope e("QPE/System", "appRaised(QString)"); e << d->appName; } else if ( msg == "flush()" ) { emit flush(); // we need to tell the desktop QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); e << d->appName; } else if ( msg == "reload()" ) { emit reload(); } else if ( msg == "setDocument(QString)" ) { d->keep_running = TRUE; QDataStream stream( data, IO_ReadOnly ); QString doc; stream >> doc; QWidget *mw = mainWidget(); if ( !mw ) mw = d->qpe_main_widget; if ( mw ) Global::setDocument( mw, doc ); } else if ( msg == "QPEProcessQCop()" ) { processQCopFile(); d->sendQCopQ(); }else { bool p = d->keep_running; d->keep_running = FALSE; emit appMessage( msg, data); if ( d->keep_running ) { d->notbusysent = FALSE; raiseAppropriateWindow(); if ( !p ) { // Tell the system we're still chugging along... #ifndef QT_NO_COP QCopEnvelope e("QPE/System", "appRaised(QString)"); e << d->appName; #endif } } if ( p ) d->keep_running = p; } #endif } /*! Sets widget \a mw as the mainWidget() and shows it. For small windows, consider passing TRUE for \a nomaximize rather than the default FALSE. \sa showMainDocumentWidget() */ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) { // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit d->show(mw, nomaximize ); } /*! Sets widget \a mw as the mainWidget() and shows it. For small windows, consider passing TRUE for \a nomaximize rather than the default FALSE. This calls designates the application as a \link docwidget.html document-oriented\endlink application. The \a mw widget \e must have this slot: setDocument(const QString&). \sa showMainWidget() */ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) { - if ( mw && argc() == 2 ) + if ( mw ) { + if ( argc() == 2 ) Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); - -// setMainWidget(mw); see above d->show(mw, nomaximize ); } +} /*! If an application is started via a \link qcop.html QCop\endlink message, the application will process the \link qcop.html QCop\endlink message and then quit. If the application calls this function while processing a \link qcop.html QCop\endlink message, after processing its outstanding \link qcop.html QCop\endlink messages the application will start 'properly' and show itself. \sa keepRunning() */ void QPEApplication::setKeepRunning() { if ( qApp && qApp->inherits( "QPEApplication" ) ) { QPEApplication * qpeApp = ( QPEApplication* ) qApp; qpeApp->d->keep_running = TRUE; } } /*! Returns TRUE if the application will quit after processing the current list of qcop messages; otherwise returns FALSE. \sa setKeepRunning() */ bool QPEApplication::keepRunning() const { return d->keep_running; } /*! \internal */ void QPEApplication::internalSetStyle( const QString &style ) { #if QT_VERSION >= 0x030000 if ( style == "QPE" ) { setStyle( new QPEStyle ); } else { QStyle *s = QStyleFactory::create( style ); if ( s ) setStyle( s ); } #else if ( style == "Windows" ) { setStyle( new QWindowsStyle ); } else if ( style == "QPE" ) { setStyle( new QPEStyle ); } else if ( style == "Light" ) { setStyle( new LightStyle ); } #ifndef QT_NO_STYLE_PLATINUM else if ( style == "Platinum" ) { setStyle( new QPlatinumStyle ); } #endif #ifndef QT_NO_STYLE_MOTIF else if ( style == "Motif" ) { setStyle( new QMotifStyle ); } #endif #ifndef QT_NO_STYLE_MOTIFPLUS else if ( style == "MotifPlus" ) { setStyle( new QMotifPlusStyle ); } #endif else { QStyle *sty = 0; QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; #ifdef Q_OS_MACX if ( style. find ( ".dylib" ) > 0 ) path += style; else path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility #else if ( style. find ( ".so" ) > 0 ) path += style; else path = path + "lib" + style. lower ( ) + ".so"; // compatibility #endif static QLibrary *lastlib = 0; static StyleInterface *lastiface = 0; QLibrary *lib = new QLibrary ( path ); StyleInterface *iface = 0; if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) sty = iface-> style ( ); if ( sty ) { diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp index 187adc6..c639002 100644 --- a/noncore/applets/pcmcia/pcmcia.cpp +++ b/noncore/applets/pcmcia/pcmcia.cpp @@ -143,192 +143,198 @@ enum { EJECT, INSERT, SUSPEND, RESUME, RESET, CONFIGURE, ACTIVATE }; static const char* actionText[] = { "eject", "insert", "suspend", "resum", "resett", "configur", "activat" }; void PcmciaManager::mousePressEvent( QMouseEvent* ) { QPopupMenu* menu = new QPopupMenu( this ); QStringList cmd; bool execute = true; OPcmciaSystem* sys = OPcmciaSystem::instance(); sys->synchronize(); OPcmciaSystem::CardIterator it = sys->iterator(); if ( !sys->count() ) return; int i = 0; while ( it.current() ) { QPopupMenu* submenu = new QPopupMenu( menu ); submenu->insertItem( "&Eject", EJECT+i*100 ); submenu->insertItem( "&Insert", INSERT+i*100 ); submenu->insertItem( "&Suspend", SUSPEND+i*100 ); submenu->insertItem( "&Resume", RESUME+i*100 ); submenu->insertItem( "Rese&t", RESET+i*100 ); submenu->insertItem( "&Configure", CONFIGURE+i*100 ); bool isSuspended = it.current()->isSuspended(); bool isEmpty = it.current()->isEmpty(); submenu->setItemEnabled( EJECT+i*100, !isEmpty ); submenu->setItemEnabled( INSERT+i*100, isEmpty ); submenu->setItemEnabled( SUSPEND+i*100, !isEmpty && !isSuspended ); submenu->setItemEnabled( RESUME+i*100, !isEmpty && isSuspended ); submenu->setItemEnabled( RESET+i*100, !isEmpty && !isSuspended ); submenu->setItemEnabled( CONFIGURE+i*100, !isEmpty && !configuring ); connect( submenu, SIGNAL(activated(int)), this, SLOT(userCardAction(int)) ); menu->insertItem( tr( "%1: %2" ).arg( i++ ).arg( it.current()->identity() ), submenu, 1 ); ++it; } QPoint p = mapToGlobal( QPoint( 0, 0 ) ); QSize s = menu->sizeHint(); int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), p.y() - s.height() ), 0 ); qDebug( "pcmcia: menu result = %d", opt ); delete menu; } void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & ) { odebug << "PcmciaManager::cardMessage( '" << msg << "' )" << oendl; if ( msg != "stabChanged()" ) return; /* check if a previously unknown card has been inserted */ OPcmciaSystem::instance()->synchronize(); if ( !OPcmciaSystem::instance()->cardCount() ) return; OConfig cfg( "PCMCIA" ); cfg.setGroup( "Global" ); int nCards = cfg.readNumEntry( "nCards", 0 ); OPcmciaSystem* sys = OPcmciaSystem::instance(); OPcmciaSystem::CardIterator it = sys->iterator(); bool newCard = true; OPcmciaSocket* theCard = 0; while ( it.current() && newCard ) { if ( it.current()->isEmpty() ) { odebug << "pcmcia: skipping empty card in socket " << it.current()->number() << oendl; ++it; continue; } else { theCard = it.current(); QString cardName = theCard->productIdentity(); for ( int i = 0; i < nCards; ++i ) { QString cardSection = QString( "Card_%1" ).arg( i ); cfg.setGroup( cardSection ); QString name = cfg.readEntry( "name" ); odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl; if ( cardName == name ) { newCard = false; odebug << "pcmcia: we have seen this card before" << oendl; executeAction( theCard, "insert" ); break; } } if ( !newCard ) ++it; else break; } } + + if ( !theCard ) { + owarn << "pcmcia: Finished working through cards in PCMCIA system but I do not have a valid card handle" << oendl; + return; + } + if ( newCard ) { odebug << "pcmcia: unconfigured card detected" << oendl; QString newCardName = theCard->productIdentity(); int result = QMessageBox::information( qApp->desktop(), tr( "PCMCIA/CF Subsystem" ), tr( "<qt>You have inserted the card<br/><b>%1</b><br/>This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ); odebug << "pcmcia: result = " << result << oendl; if ( result == 0 ) { configure( theCard ); } else { odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl; } } else // it's an already configured card { odebug << "pcmcia: doing nothing... why do we come here?" << oendl; } } void PcmciaManager::paintEvent( QPaintEvent * ) { QPainter p( this ); p.drawPixmap( 0, 0, pm ); } int PcmciaManager::position() { return 7; } void PcmciaManager::execCommand( const QStringList &strList ) { } void PcmciaManager::userCardAction( int action ) { odebug << "pcmcia: user action on socket " << action / 100 << " requested. action = " << action << oendl; int socket = action / 100; int what = action % 100; bool success = false; switch ( what ) { case CONFIGURE: { QString insertAction; QString resumeAction; QString driver; QString conf; configure( OPcmciaSystem::instance()->socket( socket ) ); return; } case EJECT: success = OPcmciaSystem::instance()->socket( socket )->eject(); break; case INSERT: success = OPcmciaSystem::instance()->socket( socket )->insert(); break; case SUSPEND: success = OPcmciaSystem::instance()->socket( socket )->suspend(); break; case RESUME: success = OPcmciaSystem::instance()->socket( socket )->resume(); break; case RESET: success = OPcmciaSystem::instance()->socket( socket )->reset(); break; case ACTIVATE: success = true; break; default: odebug << "pcmcia: not yet implemented" << oendl; } if ( success ) { odebug << tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; popUp( tr( "Successfully %1ed card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); } else { odebug << tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) << oendl; popUp( tr( "Error while %1ing card in socket #%2" ).arg( actionText[action] ).arg( socket ) ); } } void PcmciaManager::configure( OPcmciaSocket* card ) { configuring = true; ConfigDialog dialog( card, qApp->desktop() ); int result = QPEApplication::execDialog( &dialog, false ); configuring = false; odebug << "pcmcia: configresult = " << result << oendl; if ( result ) { dialog.writeConfiguration( card ); } } void PcmciaManager::executeAction( Opie::Core::OPcmciaSocket* card, const QString& type ) diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index d9e2047..8e2e2e3 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp @@ -150,214 +150,213 @@ MainWindow::~MainWindow() // --- buildList -------------------------------------------------------------- void MainWindow::buildList() { if ( cbList ) delete cbList; cbList = new QListView( this ); QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); if ( _cfg.getShowLocks() ) { cbList->addColumn( lockIcon, "", 24 ); posName = 1; } else { posName = 0; } cbList->addColumn( tr( "Checkbook Name" ) ); if ( _cfg.getShowBalances() ) { int colnum = cbList->addColumn( tr( "Balance" ) ); cbList->setColumnAlignment( colnum, Qt::AlignRight ); } cbList->setAllColumnsShowFocus( TRUE ); cbList->setSorting( posName ); QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), this, SLOT( slotEdit() ) ); setCentralWidget( cbList ); for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) { addCheckbook( cb ); } } void MainWindow::addCheckbook( CBInfo *cb ) { QListViewItem *lvi = new QListViewItem( cbList ); if ( _cfg.getShowLocks() && !cb->password().isNull() ) { lvi->setPixmap( 0, lockIcon ); } lvi->setText( posName, cb->name() ); if ( _cfg.getShowBalances() ) { QString balance; balance.sprintf( "%.2f", cb->balance() ); balance.prepend( _cfg.getCurrencySymbol() ); lvi->setText( posName + 1, balance ); } } void MainWindow::buildFilename( const QString &name ) { tempFilename = cbDir; tempFilename.append( name ); tempFilename.append( ".qcb" ); } void MainWindow::slotNew() { CBInfo *cb = new CBInfo(); Checkbook *currcb = new Checkbook( this, cb, &_cfg ); if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) { // Save new checkbook buildFilename( cb->name() ); _cfg.setLastBook( cb->name() ); cb->setFilename( tempFilename ); cb->write(); // Add to listbox checkbooks->inSort( cb ); addCheckbook( cb ); } delete currcb; } // --- slotEdit --------------------------------------------------------------- void MainWindow::slotEdit() { // get name and open it QListViewItem *curritem = cbList->currentItem(); if ( !curritem ) return; openBook( curritem ); } // --- openBook --------------------------------------------------------------- void MainWindow::openBook(QListViewItem *curritem) { + if ( !curritem ) return; // find book in List QString currname=curritem->text(posName); CBInfo *cb = checkbooks->first(); while ( cb ) { if ( cb->name() == currname ) break; cb = checkbooks->next(); } if ( !cb ) return; // buildFilename( currname ); float currbalance = cb->balance(); bool currlock = !cb->password().isNull(); if ( currlock ) { Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) { delete pw; return; } delete pw; } _cfg.setLastBook( currname ); Checkbook *currcb = new Checkbook( this, cb, &_cfg ); if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) { QString newname = cb->name(); if ( currname != newname ) { // Update name if changed - if( curritem ) { curritem->setText( posName, newname ); cbList->sort(); - } _cfg.setLastBook( newname ); // Remove old file QFile f( tempFilename ); if ( f.exists() ) f.remove(); // Get new filename buildFilename( newname ); cb->setFilename( tempFilename ); } cb->write(); // Update lock if changed if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock ) { if ( !cb->password().isNull() ) curritem->setPixmap( 0, lockIcon ); else curritem->setPixmap( 0, nullIcon ); } // Update balance if changed if ( _cfg.getShowBalances() && cb->balance() != currbalance ) { QString tempstr; tempstr.sprintf( "%.2f", cb->balance() ); tempstr.prepend( _cfg.getCurrencySymbol() ); curritem->setText( posName + 1, tempstr ); } // write config, if needed if( _cfg.isDirty() ) { Config config("checkbook"); _cfg.writeConfig( config ); } } delete currcb; } // --- slotDelete ------------------------------------------------------------- void MainWindow::slotDelete() { QString currname = cbList->currentItem()->text( posName ); if ( QPEMessageBox::confirmDelete ( this, tr( "Delete checkbook" ), currname ) ) { buildFilename( currname ); QFile f( tempFilename ); if ( f.exists() ) { f.remove(); } delete cbList->currentItem(); } } // --- slotConfigure ---------------------------------------------------------- void MainWindow::slotConfigure() { Configuration *cfgdlg = new Configuration( this, _cfg ); if ( QPEApplication::execDialog( cfgdlg ) == QDialog::Accepted ) { // read data from config dialog & save it cfgdlg->saveConfig( _cfg ); writeConfig(); buildList(); } delete cfgdlg; } // --- writeConfig -------------------------------------------------------------- void MainWindow::writeConfig() { Config config("checkbook"); _cfg.writeConfig( config ); } diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp index a44529b..5239e26 100644 --- a/noncore/apps/opie-console/procctl.cpp +++ b/noncore/apps/opie-console/procctl.cpp @@ -1,97 +1,100 @@ #include <sys/wait.h> #include <fcntl.h> #include <unistd.h> #include "procctl.h" ProcContainer *ProcCtl::m_last = 0; ProcCtl* ProcCtl::m_self = 0; ProcCtl::ProcCtl() { signal( SIGCHLD, signal_handler ); } ProcCtl::~ProcCtl() { } ProcCtl* ProcCtl::self() { if (!m_self ) { m_self = new ProcCtl; } return m_self; } void ProcCtl::add(pid_t pi, int fd ) { ProcContainer * con = new ProcContainer; //memset(con, 0, sizeof(con) ); con->pid = pi; con->fd = fd; con->status = 0; con->prev = m_last; m_last = con; } void ProcCtl::remove( pid_t pi ) { /* * We first check if the last item * is equal to pi the we * */ ProcContainer* con; if (m_last->pid == pi ) { con = m_last; m_last = con->prev; delete con; return; } con = m_last; ProcContainer* forw = 0l; while (con ) { /* remove it */ if ( pi == con->pid ) { + if (forw) forw->prev = con->prev; + else + forw = con->prev; delete con; return; } forw = con; con = con->prev; } } void ProcCtl::remove( ProcContainer con ) { remove( con.pid ); } int ProcCtl::status(pid_t pid )const{ ProcContainer *con = m_last; while (con) { if (con->pid == pid ) return con->status; con = con->prev; } return -1; } void ProcCtl::signal_handler(int) { int status; signal( SIGCHLD, signal_handler ); pid_t pi = waitpid( -1, &status, WNOHANG ); /* * find the container for pid * */ if ( pi < 0 ) { return; } ProcContainer* con = m_last; while (con) { if ( con->pid == pi ) { con->status = status; char result = 1; /* give a 'signal' */ ::write(con->fd, &result, 1 ); } con = con->prev; } } diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp index b82a86a..692fd46 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp @@ -1922,466 +1922,467 @@ void KateDocument::updateLines(int startLine, int endLine, int flags, int cursor if (line > 0) ctxNum = getTextLine(line - 1)->getContext(); do { // kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl; textLine = getTextLine(line); if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl; if (line <= endLine && line != cursorY) { if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces(); updateMaxLength(textLine); } endCtx = textLine->getContext(); // odebug << "DOHIGHLIGHT" << oendl; ctxNum = m_highlight->doHighlight(ctxNum,textLine); textLine->setContext(ctxNum); line++; } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum)); // kdDebug(13020)<<"updateLines :: while loop left"<<endl; tagLines(startLine, line - 1); } void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { int len; len = textWidth(textLine,textLine->length()); if (len > maxLength) { longestLine = textLine; maxLength = len; newDocGeometry = true; } else { if (!longestLine || (textLine == longestLine && len <= maxLength*3/4)) { maxLength = -1; for (int i = 0; i < numLines();i++) { textLine = getTextLine(i); len = textWidth(textLine,textLine->length()); if (len > maxLength) { maxLength = len; longestLine = textLine; } } newDocGeometry = true; } } } void KateDocument::slotBufferChanged() { newDocGeometry = true; //updateLines();//JW updateViews(); } void KateDocument::slotBufferHighlight(long start,long stop) { kdDebug(13020)<<"KateDocument::slotBufferHighlight"<<QString("%1-%2").arg(start).arg(stop)<<endl; updateLines(start,stop); // buffer->startLoadTimer(); } void KateDocument::updateViews(KateView *exclude) { KateView *view; int flags; bool markState = hasMarkedText(); flags = (newDocGeometry) ? KateView::ufDocGeometry : 0; for (view = views.first(); view != 0L; view = views.next() ) { if (view != exclude) view->updateView(flags); // notify every view about the changed mark state.... if (oldMarkState != markState) emit view->newMarkStatus(); } oldMarkState = markState; newDocGeometry = false; } QColor &KateDocument::cursorCol(int x, int y) { int attr; Attribute *a; TextLine::Ptr textLine = getTextLine(y); attr = textLine->getRawAttr(x); a = &m_attribs[attr & taAttrMask]; if (attr & taSelected) return a->selCol; else return a->col; } void KateDocument::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs) { paintTextLine (paint, line, 0, xStart, xEnd, showTabs); } void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, int xEnd, bool showTabs) { TextLine::Ptr textLine; int len; const QChar *s; int z, x; QChar ch; - Attribute *a = 0L; + Attribute *attrptr = 0L; int attr, nextAttr; int xs; int xc, zc; if (line > lastLine()) { paint.fillRect(0, y, xEnd - xStart,fontHeight, colors[0]); return; } textLine = getTextLine(line); len = textLine->length(); s = textLine->getText(); // skip to first visible character x = 0; z = 0; do { xc = x; zc = z; if (z == len) break; ch = s[z];//textLine->getChar(z); if (ch == '\t') { x += m_tabWidth - (x % m_tabWidth); } else { - a = &m_attribs[textLine->getAttr(z)]; + attrptr = &m_attribs[textLine->getAttr(z)]; - if (a->bold && a->italic) + if (attrptr->bold && attrptr->italic) x += myFontMetricsBI.width(ch); - else if (a->bold) + else if (attrptr->bold) x += myFontMetricsBold.width(ch); - else if (a->italic) + else if (attrptr->italic) x += myFontMetricsItalic.width(ch); else x += myFontMetrics.width(ch); } z++; } while (x <= xStart); // draw background xs = xStart; attr = textLine->getRawAttr(zc); while (x < xEnd) { nextAttr = textLine->getRawAttr(z); if ((nextAttr ^ attr) & taSelected) { if (attr & taSelected) paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[1]); else paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[0]); xs = x; attr = nextAttr; } if (z == len) break; ch = s[z];//textLine->getChar(z); if (ch == '\t') x += m_tabWidth - (x % m_tabWidth); else { - a = &m_attribs[textLine->getAttr(z)]; + attrptr = &m_attribs[textLine->getAttr(z)]; - if (a->bold && a->italic) + if (attrptr->bold && attrptr->italic) x += myFontMetricsBI.width(ch); - else if (a->bold) + else if (attrptr->bold) x += myFontMetricsBold.width(ch); - else if (a->italic) + else if (attrptr->italic) x += myFontMetricsItalic.width(ch); else x += myFontMetrics.width(ch); } z++; } if (attr & taSelected) paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[1]); else paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[0]); len = z; //reduce length to visible length // draw text x = xc; z = zc; y += fontAscent;// -1; attr = -1; while (z < len) { ch = s[z];//textLine->getChar(z); if (ch == '\t') { if (z > zc) { //this should cause no copy at all QConstString str((QChar *) &s[zc], z - zc /*+1*/); QString s = str.string(); paint.drawText(x - xStart, y, s); - if (a->bold && a->italic) + if (attrptr && attrptr->bold && attrptr->italic) x += myFontMetricsBI.width(s); - else if (a->bold) + else if (attrptr && attrptr->bold) x += myFontMetricsBold.width(s); - else if (a->italic) + else if (attrptr && attrptr->italic) x += myFontMetricsItalic.width(s); else x += myFontMetrics.width(s); } zc = z +1; if (showTabs) { nextAttr = textLine->getRawAttr(z); if (nextAttr != attr) { attr = nextAttr; - a = &m_attribs[attr & taAttrMask]; + attrptr = &m_attribs[attr & taAttrMask]; - if (attr & taSelected) paint.setPen(a->selCol); - else paint.setPen(a->col); + if (attr & taSelected) paint.setPen(attrptr->selCol); + else paint.setPen(attrptr->col); - if (a->bold && a->italic) + if (attrptr->bold && attrptr->italic) paint.setFont(myFontBI); - else if (a->bold) + else if (attrptr->bold) paint.setFont(myFontBold); - else if (a->italic) + else if (attrptr->italic) paint.setFont(myFontItalic); else paint.setFont(myFont); } -// paint.drawLine(x - xStart, y -2, x - xStart, y); -// paint.drawLine(x - xStart, y, x - xStart + 2, y); paint.drawPoint(x - xStart, y); paint.drawPoint(x - xStart +1, y); paint.drawPoint(x - xStart, y -1); } x += m_tabWidth - (x % m_tabWidth); } else { nextAttr = textLine->getRawAttr(z); if (nextAttr != attr) { if (z > zc) { QConstString str((QChar *) &s[zc], z - zc /*+1*/); QString s = str.string(); paint.drawText(x - xStart, y, s); - if (a->bold && a->italic) + if (attrptr->bold && attrptr->italic) x += myFontMetricsBI.width(s); - else if (a->bold) + else if (attrptr->bold) x += myFontMetricsBold.width(s); - else if (a->italic) + else if (attrptr->italic) x += myFontMetricsItalic.width(s); else x += myFontMetrics.width(s); zc = z; } attr = nextAttr; - a = &m_attribs[attr & taAttrMask]; + attrptr = &m_attribs[attr & taAttrMask]; - if (attr & taSelected) paint.setPen(a->selCol); - else paint.setPen(a->col); + if (attr & taSelected) paint.setPen(attrptr->selCol); + else paint.setPen(attrptr->col); - if (a->bold && a->italic) + if (attrptr->bold && attrptr->italic) paint.setFont(myFontBI); - else if (a->bold) + else if (attrptr->bold) paint.setFont(myFontBold); - else if (a->italic) + else if (attrptr->italic) paint.setFont(myFontItalic); else paint.setFont(myFont); } } z++; } if (z > zc) { QConstString str((QChar *) &s[zc], z - zc /*+1*/); paint.drawText(x - xStart, y, str.string()); } } // Applies the search context, and returns whether a match was found. If one is, // the length of the string matched is also returned. bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) { int line, col; int searchEnd; int bufLen, tlen; QChar *t; TextLine::Ptr textLine; int pos, newPos; if (searchFor.isEmpty()) return false; bufLen = 0; t = 0L; line = sc.cursor.y; col = sc.cursor.x; if (!(sc.flags & KateView::sfBackward)) { //forward search if (sc.flags & KateView::sfSelected) { if (line < selectStart) { line = selectStart; col = 0; } searchEnd = selectEnd; } else searchEnd = lastLine(); while (line <= searchEnd) { textLine = getTextLine(line); tlen = textLine->length(); if (tlen > bufLen) { delete [] t; bufLen = (tlen + 255) & (~255); t = new QChar[bufLen]; - } + } else if (!t) + t = new QChar[bufLen]; + memcpy(t, textLine->getText(), tlen*sizeof(QChar)); if (sc.flags & KateView::sfSelected) { pos = 0; do { pos = textLine->findSelected(pos); newPos = textLine->findUnselected(pos); memset(&t[pos], 0, (newPos - pos)*sizeof(QChar)); pos = newPos; } while (pos < tlen); } QString text(t, tlen); if (sc.flags & KateView::sfWholeWords) { // Until the end of the line... while (col < tlen) { // ...find the next match. col = sc.search(text, col); if (col != -1) { // Is the match delimited correctly? if (((col == 0) || (!m_highlight->isInWord(t[col]))) && ((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) { goto found; } else { // Start again from the next character. col++; } } else { // No match. break; } } } else { // Non-whole-word search. col = sc.search(text, col); if (col != -1) goto found; } col = 0; line++; } } else { // backward search if (sc.flags & KateView::sfSelected) { if (line > selectEnd) { line = selectEnd; col = -1; } searchEnd = selectStart; } else searchEnd = 0; while (line >= searchEnd) { textLine = getTextLine(line); tlen = textLine->length(); if (tlen > bufLen) { delete [] t; bufLen = (tlen + 255) & (~255); t = new QChar[bufLen]; - } + } else if (!t) + t = new QChar[bufLen]; memcpy(t, textLine->getText(), tlen*sizeof(QChar)); if (sc.flags & KateView::sfSelected) { pos = 0; do { pos = textLine->findSelected(pos); newPos = textLine->findUnselected(pos); memset(&t[pos], 0, (newPos - pos)*sizeof(QChar)); pos = newPos; } while (pos < tlen); } if (col < 0 || col > tlen) col = tlen; QString text(t, tlen); if (sc.flags & KateView::sfWholeWords) { // Until the beginning of the line... while (col >= 0) { // ...find the next match. col = sc.search(text, col); if (col != -1) { // Is the match delimited correctly? if (((col == 0) || (!m_highlight->isInWord(t[col]))) && ((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) { goto found; } else { // Start again from the previous character. col--; } } else { // No match. break; } } } else { // Non-whole-word search. col = sc.search(text, col); if (col != -1) goto found; } col = -1; line--; } } sc.flags |= KateView::sfWrapped; return false; found: if (sc.flags & KateView::sfWrapped) { if ((line > sc.startCursor.y || (line == sc.startCursor.y && col >= sc.startCursor.x)) ^ ((sc.flags & KateView::sfBackward) != 0)) return false; } sc.cursor.x = col; sc.cursor.y = line; return true; } void KateDocument::tagLine(int line) { if (tagStart > line) tagStart = line; if (tagEnd < line) tagEnd = line; } void KateDocument::insLine(int line) { KateView *view; if (selectStart >= line) selectStart++; if (selectEnd >= line) selectEnd++; if (tagStart >= line) tagStart++; if (tagEnd >= line) tagEnd++; newDocGeometry = true; for (view = views.first(); view != 0L; view = views.next() ) { view->insLine(line); } } void KateDocument::delLine(int line) { KateView *view; if (selectStart >= line && selectStart > 0) selectStart--; if (selectEnd >= line) selectEnd--; if (tagStart >= line && tagStart > 0) tagStart--; if (tagEnd >= line) tagEnd--; newDocGeometry = true; for (view = views.first(); view != 0L; view = views.next() ) { view->delLine(line); } } void KateDocument::optimizeSelection() { TextLine::Ptr textLine; while (selectStart <= selectEnd) { diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp index 164d608..428cfd4 100644 --- a/noncore/settings/sysinfo/devicesinfo.cpp +++ b/noncore/settings/sysinfo/devicesinfo.cpp @@ -172,193 +172,193 @@ void CpuCategory::populate() //================================================================================================= InputCategory::InputCategory( DevicesView* parent ) :Category( parent, "2. Input Subsystem" ) { } InputCategory::~InputCategory() { } void InputCategory::populate() { odebug << "InputCategory::populate()" << oendl; OInputSystem* sys = OInputSystem::instance(); OInputSystem::DeviceIterator it = sys->iterator(); while ( it.current() ) { InputDevice* dev = new InputDevice( this, it.current()->identity() ); dev->setInfo( it.current() ); ++it; } } //================================================================================================= CardsCategory::CardsCategory( DevicesView* parent ) :Category( parent, "3. Removable Cards" ) { } CardsCategory::~CardsCategory() { } void CardsCategory::populate() { odebug << "CardsCategory::populate()" << oendl; OPcmciaSystem* sys = OPcmciaSystem::instance(); OPcmciaSystem::CardIterator it = sys->iterator(); while ( it.current() ) { CardDevice *dev = new CardDevice( this, it.current()->identity() ); dev->setInfo( it.current() ); ++it; } } //================================================================================================= UsbCategory::UsbCategory( DevicesView* parent ) :Category( parent, "4. Universal Serial Bus" ) { } UsbCategory::~UsbCategory() { } void UsbCategory::populate() { odebug << "UsbCategory::populate()" << oendl; QFile usbinfofile( "/proc/bus/usb/devices" ); if ( !usbinfofile.exists() || !usbinfofile.open( IO_ReadOnly ) ) { new UsbDevice( this, "(no USB found)" ); return; } QTextStream usbinfo( &usbinfofile ); int _bus, _level, _parent, _port, _count, _device, _channels, _power; float _speed; QString _manufacturer, _product, _serial; int usbcount = 0; UsbDevice* lastDev = 0; UsbDevice* dev = 0; while ( !usbinfo.atEnd() ) { QString line = usbinfo.readLine(); odebug << "got line '" << line << "'" << oendl; if ( line.startsWith( "T:" ) ) { sscanf(line.local8Bit().data(), "T: Bus=%2d Lev=%2d Prnt=%2d Port=%d Cnt=%2d Dev#=%3d Spd=%3f MxCh=%2d", &_bus, &_level, &_parent, &_port, &_count, &_device, &_speed, &_channels); if ( !_level ) { odebug << "adding new bus" << oendl; dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) ); lastDev = dev; } else { odebug << "adding new dev" << oendl; dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) ); lastDev = dev; } } - else if ( line.startsWith( "S: Product" ) ) + else if ( dev && line.startsWith( "S: Product" ) ) { int dp = line.find( '=' ); dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" ); } else { continue; } } } //================================================================================================= Device::Device( Category* parent, const QString& name ) :OListViewItem( parent, name ) { devinfo = static_cast<QWidget*>( listView()->parent() ); } Device::Device( Device* parent, const QString& name ) :OListViewItem( parent, name ) { devinfo = static_cast<QWidget*>( listView()->parent() ); } Device::~Device() { } QWidget* Device::detailsWidget() { return details; } //================================================================================================= CpuDevice::CpuDevice( Category* parent, const QString& name ) :Device( parent, name ) { OListView* w = new OListView( devinfo ); details = w; w->addColumn( "Info" ); w->addColumn( "Value" ); w->hide(); } CpuDevice::~CpuDevice() { } void CpuDevice::addInfo( const QString& info ) { int dp = info.find( ':' ); if ( dp != -1 ) { new OListViewItem( (OListView*) details, info.left( dp ), info.right( info.length()-dp ) ); } } //================================================================================================= CardDevice::CardDevice( Category* parent, const QString& name ) :Device( parent, name ) { OListView* w = new OListView( devinfo ); details = w; w->addColumn( "Info" ); w->addColumn( "Value" ); w->hide(); } void CardDevice::setInfo( const OPcmciaSocket* card ) { QStringList vendorlst = card->productIdentityVector(); for( QStringList::Iterator it = vendorlst.begin(); it != vendorlst.end(); ++it ) { new OListViewItem( (OListView*) details, "VendorID", *it ); } new OListViewItem( (OListView*) details, "Manufacturer", card->manufacturerIdentity() ); new OListViewItem( (OListView*) details, "Function", card->function() ); QStringList text; OPcmciaSocket::OPcmciaSocketCardStatus status = card->status(); if ( status ) { if ( status & OPcmciaSocket::Occupied ) text += "Occupied"; if ( status & OPcmciaSocket::OccupiedCardBus ) text += "CardBus"; if ( status & OPcmciaSocket::WriteProtected ) text += "WriteProtected"; if ( status & OPcmciaSocket::BatteryLow ) text += "BatteryLow"; if ( status & OPcmciaSocket::BatteryDead ) text += "BatteryDead"; if ( status & OPcmciaSocket::Ready ) text += "Ready"; if ( status & OPcmciaSocket::Suspended ) text += "Suspended"; if ( status & OPcmciaSocket::Attention ) text += "Attention"; if ( status & OPcmciaSocket::InsertionInProgress ) text += "InsertionInProgress"; if ( status & OPcmciaSocket::RemovalInProgress ) text += "RemovalInProgress"; if ( status & OPcmciaSocket::ThreeVolts ) text += "3V"; if ( status & OPcmciaSocket::SupportsVoltage ) text += "SupportsVoltage"; diff --git a/noncore/todayplugins/stockticker/libstocks/http.c b/noncore/todayplugins/stockticker/libstocks/http.c index 2f38f8a..cc78ab7 100644 --- a/noncore/todayplugins/stockticker/libstocks/http.c +++ b/noncore/todayplugins/stockticker/libstocks/http.c @@ -117,187 +117,187 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata) #elif __WINDOWS__ closesocket(s); #endif return ERRCONN; } /* create header */ if (http_proxy_server) { sprintf(header,"GET http://%.128s:80%.256s HTTP/1.0\015\012\015\012", http_server, http_file); } else { sprintf(header,"GET %s HTTP/1.0\015\012\015\012",http_file); } hlg=strlen(header); /* send header */ #ifdef __UNIX__ if (write(s,header,hlg)!=hlg) #elif __WINDOWS__ if (send(s,header,hlg, 0)!=hlg) #endif { #ifdef DEBUG printf(" send header : NOK\n"); #endif return ERRWHEA; } data_lgr = 0; r=1; while(r) { /* Clear Buffer */ memset(buf,0,BUF_SIZE+1); #ifdef __UNIX__ r=read(s,buf,BUF_SIZE); #elif __WINDOWS__ r=recv(s,buf,BUF_SIZE,0); #endif if (r) { if(!data_lgr) { if((data = malloc(r+1))==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } memcpy(data,buf,r); data_lgr = r; data[r]=0; } else { if((temp = malloc(r+data_lgr+1))==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } memcpy(temp, data, data_lgr); memcpy(temp+data_lgr, buf, r); temp[r+data_lgr]=0; data_lgr += r; free(data); data = temp; } } } /* close socket */ #ifdef __UNIX__ close(s); #elif __WINDOWS__ closesocket(s); #endif #ifdef DEBUG printf("%s\n", data); #endif /* get headers to test status line */ /* and to split headers and content */ temp = data; header_founded = 0; while( !header_founded ) { - if (*temp==0) return ERRRHEA; + if (!temp || *temp==0) return ERRRHEA; if( *temp==0x0A ) { /* test if it is the header end */ temp ++; if (*temp == 0x0D) temp++; if (*temp == 0x0A) header_founded = 1; } else temp++; } *temp = 0; temp++; sscanf(data,"HTTP/1.%*d %03d",&error_code); if (error_code != 200) { #ifdef DEBUG printf(" HTTP error code : %d\n", error_code); #endif free(data); return ERRPAHD; } if ((csv_ptr = malloc(strlen(temp)+1))==NULL) { free(data); fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } memcpy(csv_ptr, temp, strlen(temp)+1); free(data); #ifdef DEBUG printf(" CSV\n"); printf("%s,\n", csv_ptr); #endif *pdata = csv_ptr; return 0; } /******************************************************************************/ /* Set the proxy server to use */ /******************************************************************************/ libstocks_return_code set_proxy(char *proxy) { char *ptr; char c; #ifdef DEBUG printf("*set_proxy\n"); #endif /* Parse the proxy URL - It must start with http:// */ #ifdef __UNIX__ if (strncasecmp("http://",proxy,7)) return ERRPROX; #elif __WINDOWS__ if (_mbsnbicmp("http://",proxy,7)) return ERRPROX; #endif proxy+=7; /* find ":" in the proxy url */ ptr = proxy; for (c=*ptr; (c && c!=':');) c=*ptr++; /* ptr points just after the ":" or at the end of proxy if : not founded */ *(ptr-1)=0; /* clear the ":" */ http_proxy_server=strdup(proxy); #ifdef DEBUG printf("http_proxy_server : %s\n", http_proxy_server); #endif /* get the port number of the url */ if (sscanf(ptr,"%d",&http_proxy_port)!=1) return ERRPROX; #ifdef DEBUG printf("http_proxy_port : %d\n", http_proxy_port); #endif return 0; } |