diff options
author | Timothy Pearson <[email protected]> | 2013-03-21 16:21:25 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-03-21 16:21:25 -0500 |
commit | f5b03149e8e68e510efe9842d85a058b42a51264 (patch) | |
tree | 49c476a64e7377ecf25a949a9116fc7bf89c4cf5 | |
parent | 1b0a52a0c1285bf6237aac3fbd99eaebeca5663a (diff) | |
download | tqt3-f5b03149e8e68e510efe9842d85a058b42a51264.tar.gz tqt3-f5b03149e8e68e510efe9842d85a058b42a51264.zip |
Automated update from Qt3
-rw-r--r-- | src/tools/ntqstring.h | 14 | ||||
-rw-r--r-- | src/tools/qstring.cpp | 79 | ||||
-rw-r--r-- | src/widgets/ntqlineedit.h | 2 | ||||
-rw-r--r-- | src/widgets/qlineedit.cpp | 46 | ||||
-rw-r--r-- | tools/designer/designer/designerappiface.cpp | 4 | ||||
-rw-r--r-- | tools/designer/designer/designerappiface.h | 1 | ||||
-rw-r--r-- | tools/designer/interfaces/designerinterface.h | 21 |
7 files changed, 153 insertions, 14 deletions
diff --git a/src/tools/ntqstring.h b/src/tools/ntqstring.h index 29704e719..b91caf83c 100644 --- a/src/tools/ntqstring.h +++ b/src/tools/ntqstring.h @@ -360,11 +360,10 @@ inline bool operator>( TQChar c1, TQChar c2 ) { return !(c2>=c1); } // internal struct Q_EXPORT TQStringData : public TQShared { TQStringData() : - TQShared(), unicode(0), ascii(0), len(0), issimpletext(TRUE), maxl(0), islatin1(FALSE) { ref(); } + TQShared(), unicode(0), ascii(0), len(0), issimpletext(TRUE), maxl(0), islatin1(FALSE), security_unpaged(FALSE) { ref(); } TQStringData(TQChar *u, uint l, uint m) : - TQShared(), unicode(u), ascii(0), len(l), issimpletext(FALSE), maxl(m), islatin1(FALSE) { } - ~TQStringData() { if ( unicode ) delete[] ((char*)unicode); - if ( ascii ) delete[] ascii; } + TQShared(), unicode(u), ascii(0), len(l), issimpletext(FALSE), maxl(m), islatin1(FALSE), security_unpaged(FALSE) { } + ~TQStringData(); void deleteSelf(); TQChar *unicode; @@ -389,6 +388,8 @@ struct Q_EXPORT TQStringData : public TQShared { #endif uint islatin1 : 1; + bool security_unpaged : 1; + private: #if defined(TQ_DISABLE_COPY) TQStringData( const TQStringData& ); @@ -750,7 +751,12 @@ private: // needed for TQDeepCopy void detach(); + + void setSecurityUnPaged(bool lock); + static char* unicodeToLatin1( const TQChar*, uint len, bool unpaged ); + friend class TQDeepCopy<TQString>; + friend class TQLineEdit; }; class Q_EXPORT TQCharRef { diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp index 86ba42469..878f3e60f 100644 --- a/src/tools/qstring.cpp +++ b/src/tools/qstring.cpp @@ -65,10 +65,18 @@ #if defined(Q_WS_WIN) #include "qt_windows.h" #endif +#if defined(Q_OS_LINUX) +#include <sys/mman.h> +#endif #if !defined( QT_NO_COMPONENT ) && !defined( QT_LITE_COMPONENT ) #include "ntqcleanuphandler.h" #endif +#if defined(Q_OS_LINUX) +#define LINUX_MEMLOCK_LIMIT_BYTES 16384 +#define LINUX_MEMLOCK_LIMIT_CHARACTERS LINUX_MEMLOCK_LIMIT_BYTES/sizeof(TQChar) +#endif + #ifndef LLONG_MAX #define LLONG_MAX TQ_INT64_C(9223372036854775807) #endif @@ -1025,6 +1033,14 @@ static inline bool format(TQChar::Decomposition tag, TQString & str, } // format() #endif +TQStringData::~TQStringData() { + if ( unicode ) delete[] ((char*)unicode); + if ( ascii && security_unpaged ) { + munlock(ascii, LINUX_MEMLOCK_LIMIT_BYTES); + } + if ( ascii ) delete[] ascii; +} + /* TQString::compose() and visual() were developed by Gordon Tisher <[email protected]>, with input from Lars Knoll <[email protected]>, @@ -1203,19 +1219,34 @@ static TQChar* internalLatin1ToUnicode( const char *str, uint* len, } /*! + ABI compatibility +*/ + +char* TQString::unicodeToLatin1(const TQChar *uc, uint l) +{ + return unicodeToLatin1(uc, l, false); +} + +/*! This utility function converts \a l 16-bit characters from \a uc to ASCII, returning a '\0'-terminated string. The caller is responsible for deleting the resultant string with delete[]. */ -char* TQString::unicodeToLatin1(const TQChar *uc, uint l) + +char* TQString::unicodeToLatin1(const TQChar *uc, uint l, bool unpaged) { if (!uc) { return 0; } char *a = new char[l+1]; char *result = a; + if (unpaged) { +#if defined(Q_OS_LINUX) + mlock(result, LINUX_MEMLOCK_LIMIT_BYTES); +#endif + } while (l--) { *a++ = (uc->unicode() > 0xff) ? '?' : (char)uc->unicode(); uc++; @@ -1707,8 +1738,10 @@ void TQString::setLength( uint newLen ) if ( nd ) { uint len = TQMIN( d->len, newLen ); memcpy( nd, d->unicode, sizeof(TQChar) * len ); + bool unpaged = d->security_unpaged; deref(); d = new TQStringData( nd, newLen, newMax ); + setSecurityUnPaged(unpaged); } } else { d->len = newLen; @@ -1760,8 +1793,10 @@ void TQString::reserve( uint minCapacity ) uint len = d->len; if ( len ) memcpy( nd, d->unicode, sizeof(TQChar) * len ); + bool unpaged = d->security_unpaged; deref(); d = new TQStringData( nd, len, minCapacity ); + setSecurityUnPaged(unpaged); } } } @@ -1780,8 +1815,10 @@ void TQString::squeeze() uint len = d->len; if ( len ) memcpy( nd, d->unicode, sizeof(TQChar) * len ); + bool unpaged = d->security_unpaged; deref(); d = new TQStringData( nd, len, len ); + setSecurityUnPaged(unpaged); } } } @@ -2744,9 +2781,11 @@ TQString& TQString::fill( TQChar c, int len ) if ( len == 0 ) { *this = ""; } else { + bool unpaged = d->security_unpaged; deref(); TQChar * nd = QT_ALLOC_QCHAR_VEC( len ); d = new TQStringData(nd,len,len); + setSecurityUnPaged(unpaged); while (len--) *nd++ = c; } return *this; @@ -5678,8 +5717,15 @@ TQString &TQString::operator+=( char c ) const char* TQString::latin1() const { if ( !d->ascii || !d->islatin1 ) { + if (d->security_unpaged) { +#if defined(Q_OS_LINUX) + if (d->ascii) { + munlock(d->ascii, LINUX_MEMLOCK_LIMIT_BYTES); + } +#endif + } delete [] d->ascii; - d->ascii = unicodeToLatin1( d->unicode, d->len ); + d->ascii = unicodeToLatin1( d->unicode, d->len, d->security_unpaged ); d->islatin1 = TRUE; } return d->ascii; @@ -5699,10 +5745,22 @@ const char* TQString::ascii() const #ifndef QT_NO_TEXTCODEC if ( TQTextCodec::codecForCStrings() ) { if ( !d->ascii || d->islatin1 ) { + if (d->security_unpaged) { +#if defined(Q_OS_LINUX) + if (d->ascii) { + munlock(d->ascii, LINUX_MEMLOCK_LIMIT_BYTES); + } +#endif + } delete [] d->ascii; if (d->unicode) { TQCString s = TQTextCodec::codecForCStrings()->fromUnicode( *this ); d->ascii = new char[s.length() + 1]; + if (d->security_unpaged) { +#if defined(Q_OS_LINUX) + mlock(d->ascii, LINUX_MEMLOCK_LIMIT_BYTES); +#endif + } memcpy(d->ascii, s.data(), s.length() + 1); } else { d->ascii = 0; @@ -5715,6 +5773,23 @@ const char* TQString::ascii() const return latin1(); } +void TQString::setSecurityUnPaged(bool lock) { + if (lock != d->security_unpaged) { + if (d->security_unpaged) { + if (d->ascii) { + munlock(d->ascii, LINUX_MEMLOCK_LIMIT_BYTES); + } + d->security_unpaged = false; + } + else { + if (d->ascii) { + mlock(d->ascii, LINUX_MEMLOCK_LIMIT_BYTES); + } + d->security_unpaged = true; + } + } +} + /*! Returns the string encoded in UTF-8 format. diff --git a/src/widgets/ntqlineedit.h b/src/widgets/ntqlineedit.h index 9a2305608..f8aecede7 100644 --- a/src/widgets/ntqlineedit.h +++ b/src/widgets/ntqlineedit.h @@ -94,7 +94,7 @@ public: bool frame() const; - enum EchoMode { Normal, NoEcho, Password }; + enum EchoMode { Normal, NoEcho, Password, PasswordThreeStars }; EchoMode echoMode() const; bool isReadOnly() const; diff --git a/src/widgets/qlineedit.cpp b/src/widgets/qlineedit.cpp index 3ba828c18..2cc64e017 100644 --- a/src/widgets/qlineedit.cpp +++ b/src/widgets/qlineedit.cpp @@ -63,6 +63,9 @@ #include "../kernel/qinternal_p.h" #include "private/qtextlayout_p.h" #include "ntqvaluevector.h" +#if defined(Q_OS_LINUX) +#include <sys/mman.h> +#endif #if defined(QT_ACCESSIBILITY_SUPPORT) #include "ntqaccessible.h" #endif @@ -74,6 +77,11 @@ #define ACCEL_KEY(k) "\t" + TQString("Ctrl+" #k) #endif +#if defined(Q_OS_LINUX) +#define LINUX_MEMLOCK_LIMIT_BYTES 16384 +#define LINUX_MEMLOCK_LIMIT_CHARACTERS LINUX_MEMLOCK_LIMIT_BYTES/sizeof(TQChar) +#endif + #define innerMargin 1 struct TQLineEditPrivate : public TQt @@ -451,6 +459,10 @@ TQLineEdit::TQLineEdit( const TQString& contents, const TQString &inputMask, TQW TQLineEdit::~TQLineEdit() { + if ((d->echoMode == NoEcho) || (d->echoMode == Password) || (d->echoMode == PasswordThreeStars)) { + d->text.fill(TQChar(0)); + munlock(d->text.d->unicode, LINUX_MEMLOCK_LIMIT_BYTES); + } delete [] d->maskData; delete d; } @@ -500,11 +512,16 @@ void TQLineEdit::setText( const TQString& text) TQString TQLineEdit::displayText() const { - if ( d->echoMode == NoEcho ) + if ( d->echoMode == NoEcho ) { return TQString::fromLatin1(""); + } TQString res = d->text; - if ( d->echoMode == Password ) + if ( d->echoMode == Password ) { res.fill( passwordChar() ); + } + else if ( d->echoMode == PasswordThreeStars ) { + res.fill( passwordChar(), res.length()*3 ); + } return ( res.isNull() ? TQString::fromLatin1("") : res ); } @@ -598,11 +615,26 @@ TQLineEdit::EchoMode TQLineEdit::echoMode() const void TQLineEdit::setEchoMode( EchoMode mode ) { - if (mode == (EchoMode)d->echoMode) + if (mode == (EchoMode)d->echoMode) { return; + } +#if defined(Q_OS_LINUX) + if (((mode == NoEcho) || (mode == Password) || (mode == PasswordThreeStars)) && ((EchoMode)d->echoMode == Normal)) { + if ((uint)d->maxLength > (LINUX_MEMLOCK_LIMIT_CHARACTERS-1)) { + d->maxLength = LINUX_MEMLOCK_LIMIT_CHARACTERS-1; + } + d->text.reserve(LINUX_MEMLOCK_LIMIT_CHARACTERS); + mlock(d->text.d->unicode, LINUX_MEMLOCK_LIMIT_BYTES); + d->text.setSecurityUnPaged(true); + } + else { + d->text.setSecurityUnPaged(false); + munlock(d->text.d->unicode, LINUX_MEMLOCK_LIMIT_BYTES); + } +#endif d->echoMode = mode; d->updateTextLayout(); - setInputMethodEnabled( mode == Normal ); + setInputMethodEnabled( ( mode == Normal ) || ( mode == Password) ); update(); } @@ -1688,12 +1720,12 @@ void TQLineEdit::keyPressEvent( TQKeyEvent * e ) case Key_Right: case Key_Left: if ( d->isRightToLeft() == (e->key() == Key_Right) ) { - if ( echoMode() == Normal ) + if (( echoMode() == Normal ) || ( echoMode() == Password )) cursorWordBackward( e->state() & ShiftButton ); else home( e->state() & ShiftButton ); } else { - if ( echoMode() == Normal ) + if (( echoMode() == Normal ) || ( echoMode() == Password )) cursorWordForward( e->state() & ShiftButton ); else end( e->state() & ShiftButton ); @@ -2069,7 +2101,7 @@ void TQLineEdit::drawContents( TQPainter *p ) // Asian users regard IM selection text as cursor on candidate // selection phase of input method, so ordinary cursor should be // invisible if IM selection text exists. - if ( d->cursorVisible && !supressCursor && !d->hasIMSelection() ) { + if ( d->cursorVisible && !supressCursor && !d->hasIMSelection() && (d->echoMode != PasswordThreeStars) ) { TQPoint from( topLeft.x() + cix, lineRect.top() ); TQPoint to = from + TQPoint( 0, lineRect.height() ); p->drawLine( from, to ); diff --git a/tools/designer/designer/designerappiface.cpp b/tools/designer/designer/designerappiface.cpp index 4cba8db7f..98aa69e52 100644 --- a/tools/designer/designer/designerappiface.cpp +++ b/tools/designer/designer/designerappiface.cpp @@ -58,6 +58,10 @@ DesignerInterfaceImpl::DesignerInterfaceImpl( MainWindow *mw ) { } +DesignerInterfaceImpl::~DesignerInterfaceImpl() +{ +} + TQRESULT DesignerInterfaceImpl::queryInterface( const TQUuid &uuid, TQUnknownInterface** iface ) { *iface = 0; diff --git a/tools/designer/designer/designerappiface.h b/tools/designer/designer/designerappiface.h index 7f65f0e57..7b5719b45 100644 --- a/tools/designer/designer/designerappiface.h +++ b/tools/designer/designer/designerappiface.h @@ -47,6 +47,7 @@ class DesignerInterfaceImpl : public DesignerInterface { public: DesignerInterfaceImpl( MainWindow *mw ); + virtual ~DesignerInterfaceImpl(); DesignerProject *currentProject() const; DesignerFormWindow *currentForm() const; diff --git a/tools/designer/interfaces/designerinterface.h b/tools/designer/interfaces/designerinterface.h index e0f5952b1..31b750e95 100644 --- a/tools/designer/interfaces/designerinterface.h +++ b/tools/designer/interfaces/designerinterface.h @@ -108,6 +108,9 @@ struct DesignerInterface : public TQUnknownInterface struct DesignerProject { + DesignerProject() {} + virtual ~DesignerProject() {} + virtual TQPtrList<DesignerFormWindow> formList() const = 0; virtual TQStringList formNames() const = 0; virtual TQString formFileName( const TQString &form ) const = 0; @@ -149,6 +152,9 @@ struct DesignerProject struct DesignerDatabase { + DesignerDatabase() {} + virtual ~DesignerDatabase() {} + virtual TQString name() const = 0; virtual void setName( const TQString & ) = 0; virtual TQString driver() const = 0; @@ -173,12 +179,18 @@ struct DesignerDatabase struct DesignerPixmapCollection { + DesignerPixmapCollection() {} + virtual ~DesignerPixmapCollection() {} + virtual void addPixmap( const TQPixmap &p, const TQString &name, bool force ) = 0; virtual TQPixmap pixmap( const TQString &name ) const = 0; }; struct DesignerFormWindow { + DesignerFormWindow() {} + virtual ~DesignerFormWindow() {} + virtual TQString name() const = 0; virtual void setName( const TQString &n ) = 0; virtual TQString fileName() const = 0; @@ -248,16 +260,25 @@ struct DesignerFormWindow struct DesignerSourceFile { + DesignerSourceFile() {} + virtual ~DesignerSourceFile() {} + virtual TQString fileName() const = 0; }; struct DesignerDock { + DesignerDock() {} + virtual ~DesignerDock() {} + virtual TQDockWindow *dockWindow() const = 0; }; struct DesignerOutputDock { + DesignerOutputDock() {} + virtual ~DesignerOutputDock() {} + virtual TQWidget *addView( const TQString &pageName ) = 0; virtual void appendDebug( const TQString & ) = 0; virtual void clearDebug() = 0; |