Qt 4.8
Public Functions | Static Public Functions | Public Variables | Properties | List of all members
QSharedMemoryPrivate Class Reference

#include <qsharedmemory_p.h>

Inheritance diagram for QSharedMemoryPrivate:
QObjectPrivate QObjectData

Public Functions

bool attach (QSharedMemory::AccessMode mode)
 
void cleanHandle ()
 
bool create (int size)
 
bool detach ()
 
HANDLE handle ()
 If not already made create the handle used for accessing the shared memory. More...
 
bool initKey ()
 
 QSharedMemoryPrivate ()
 
void setErrorString (const QString &function)
 
bool tryLocker (QSharedMemoryLocker *locker, const QString &function)
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static int createUnixKeyFile (const QString &fileName)
 Creates the unix file if needed. More...
 
static QString makePlatformSafeKey (const QString &key, const QString &prefix=QLatin1String("qipc_sharedmemory_"))
 Generate a string from the key which can be any unicode string into the subset that the win/unix kernel allows. More...
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

QSharedMemory::SharedMemoryError error
 
QString errorString
 
QString key
 
bool lockedByMe
 
void * memory
 
QString nativeKey
 
int size
 
QSystemSemaphore systemSemaphore
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Properties

HANDLE hand
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 115 of file qsharedmemory_p.h.

Constructors and Destructors

◆ QSharedMemoryPrivate()

QSharedMemoryPrivate::QSharedMemoryPrivate ( )

Definition at line 72 of file qsharedmemory_unix.cpp.

74 #ifndef QT_NO_SYSTEMSEMAPHORE
76 #endif
77 #ifndef QT_POSIX_IPC
78  unix_key(0)
79 #else
80  hand(0)
81 #endif
82 {
83 }
QSharedMemory::SharedMemoryError error
QSystemSemaphore systemSemaphore
The QString class provides a Unicode character string.
Definition: qstring.h:83
QObjectPrivate(int version=QObjectPrivateVersion)
Definition: qobject.cpp:133

Functions

◆ attach()

bool QSharedMemoryPrivate::attach ( QSharedMemory::AccessMode  mode)

Definition at line 298 of file qsharedmemory_unix.cpp.

299 {
300 #ifndef QT_POSIX_IPC
301  // grab the shared memory segment id
302  int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0400 : 0600));
303  if (-1 == id) {
304  setErrorString(QLatin1String("QSharedMemory::attach (shmget)"));
305  return false;
306  }
307 
308  // grab the memory
309  memory = shmat(id, 0, (mode == QSharedMemory::ReadOnly ? SHM_RDONLY : 0));
310  if ((void*) - 1 == memory) {
311  memory = 0;
312  setErrorString(QLatin1String("QSharedMemory::attach (shmat)"));
313  return false;
314  }
315 
316  // grab the size
317  shmid_ds shmid_ds;
318  if (!shmctl(id, IPC_STAT, &shmid_ds)) {
319  size = (int)shmid_ds.shm_segsz;
320  } else {
321  setErrorString(QLatin1String("QSharedMemory::attach (shmctl)"));
322  return false;
323  }
324 #else
326 
327  int oflag = (mode == QSharedMemory::ReadOnly ? O_RDONLY : O_RDWR);
328  mode_t omode = (mode == QSharedMemory::ReadOnly ? 0444 : 0660);
329 
330  EINTR_LOOP(hand, shm_open(shmName.constData(), oflag, omode));
331  if (hand == -1) {
332  QString function = QLatin1String("QSharedMemory::attach (shm_open)");
333  switch (errno) {
334  case ENAMETOOLONG:
335  case EINVAL:
336  errorString = QSharedMemory::tr("%1: bad name").arg(function);
338  break;
339  default:
340  setErrorString(function);
341  }
342  hand = 0;
343  return false;
344  }
345 
346  // grab the size
347  QT_STATBUF st;
348  if (QT_FSTAT(hand, &st) == -1) {
349  setErrorString(QLatin1String("QSharedMemory::attach (fstat)"));
350  cleanHandle();
351  return false;
352  }
353  size = st.st_size;
354 
355  // grab the memory
356  int mprot = (mode == QSharedMemory::ReadOnly ? PROT_READ : PROT_READ | PROT_WRITE);
357  memory = mmap(0, size, mprot, MAP_SHARED, hand, 0);
358  if (memory == MAP_FAILED || !memory) {
359  setErrorString(QLatin1String("QSharedMemory::attach (mmap)"));
360  cleanHandle();
361  memory = 0;
362  size = 0;
363  return false;
364  }
365 #endif // QT_POSIX_IPC
366 
367  return true;
368 }
#define MAP_FAILED
QSharedMemory::SharedMemoryError error
#define EINTR_LOOP(var, cmd)
Definition: qcore_unix_p.h:96
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void setErrorString(const QString &function)
#define O_RDONLY
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
int mode_t
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
#define st(var, type, card)
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528
static QString makePlatformSafeKey(const QString &key, const QString &prefix=QLatin1String("qipc_sharedmemory_"))
Generate a string from the key which can be any unicode string into the subset that the win/unix kern...
#define O_RDWR
int errno

◆ cleanHandle()

void QSharedMemoryPrivate::cleanHandle ( )

Definition at line 217 of file qsharedmemory_unix.cpp.

Referenced by attach(), and detach().

218 {
219 #ifndef QT_POSIX_IPC
220  unix_key = 0;
221 #else
223  hand = 0;
224 #endif
225 }
static int qt_safe_close(int fd)
Definition: qcore_unix_p.h:297

◆ create()

bool QSharedMemoryPrivate::create ( int  size)

Definition at line 227 of file qsharedmemory_unix.cpp.

228 {
229 #ifndef QT_POSIX_IPC
230  // build file if needed
231  int built = createUnixKeyFile(nativeKey);
232  if (built == -1) {
233  errorString = QSharedMemory::tr("%1: unable to make key").arg(QLatin1String("QSharedMemory::create"));
235  return false;
236  }
237  bool createdFile = built == 1;
238 
239  // get handle
240  if (!handle()) {
241  if (createdFile)
243  return false;
244  }
245 
246  // create
247  if (-1 == shmget(unix_key, size, 0600 | IPC_CREAT | IPC_EXCL)) {
248  QString function = QLatin1String("QSharedMemory::create");
249  switch (errno) {
250  case EINVAL:
251  errorString = QSharedMemory::tr("%1: system-imposed size restrictions").arg(function);
253  break;
254  default:
255  setErrorString(function);
256  }
257  if (createdFile && error != QSharedMemory::AlreadyExists)
259  return false;
260  }
261 #else
262  if (!handle())
263  return false;
264 
266 
267  int fd;
268  EINTR_LOOP(fd, shm_open(shmName.constData(), O_RDWR | O_CREAT | O_EXCL, 0666));
269  if (fd == -1) {
270  QString function = QLatin1String("QSharedMemory::create");
271  switch (errno) {
272  case ENAMETOOLONG:
273  case EINVAL:
274  errorString = QSharedMemory::tr("%1: bad name").arg(function);
276  break;
277  default:
278  setErrorString(function);
279  }
280  return false;
281  }
282 
283  // the size may only be set once; ignore errors
284  int ret;
285  EINTR_LOOP(ret, ftruncate(fd, size));
286  if (ret == -1) {
287  setErrorString(QLatin1String("QSharedMemory::create (ftruncate)"));
288  qt_safe_close(fd);
289  return false;
290  }
291 
292  qt_safe_close(fd);
293 #endif // QT_POSIX_IPC
294 
295  return true;
296 }
QSharedMemory::SharedMemoryError error
#define EINTR_LOOP(var, cmd)
Definition: qcore_unix_p.h:96
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void setErrorString(const QString &function)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static int qt_safe_close(int fd)
Definition: qcore_unix_p.h:297
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define O_CREAT
HANDLE handle()
If not already made create the handle used for accessing the shared memory.
static int createUnixKeyFile(const QString &fileName)
Creates the unix file if needed.
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
bool remove()
Removes the file specified by fileName().
Definition: qfile.cpp:715
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528
static QString makePlatformSafeKey(const QString &key, const QString &prefix=QLatin1String("qipc_sharedmemory_"))
Generate a string from the key which can be any unicode string into the subset that the win/unix kern...
#define O_RDWR
#define O_EXCL
int errno

◆ createUnixKeyFile()

int QSharedMemoryPrivate::createUnixKeyFile ( const QString fileName)
static

Creates the unix file if needed.

Warning
This function is not part of the public interface.

returns true if the unix file was created.

-1 error 0 already existed 1 created

Definition at line 191 of file qsharedmemory_unix.cpp.

Referenced by create(), and QSystemSemaphorePrivate::handle().

192 {
193 #ifndef QT_POSIX_IPC
194  if (QFile::exists(fileName))
195  return 0;
196 
197  int fd = qt_safe_open(QFile::encodeName(fileName).constData(),
198  O_EXCL | O_CREAT | O_RDWR, 0640);
199  if (-1 == fd) {
200  if (errno == EEXIST)
201  return 0;
202  return -1;
203  } else {
204  qt_safe_close(fd);
205  }
206  return 1;
207 #else
208  Q_UNUSED(fileName);
209  // nothing to do
210  return -1;
211 #endif
212 }
static int qt_safe_close(int fd)
Definition: qcore_unix_p.h:297
#define O_CREAT
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
Definition: qcore_unix_p.h:171
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
#define O_RDWR
#define O_EXCL
int errno

◆ detach()

bool QSharedMemoryPrivate::detach ( )

Definition at line 370 of file qsharedmemory_unix.cpp.

371 {
372 #ifndef QT_POSIX_IPC
373  // detach from the memory segment
374  if (-1 == shmdt(memory)) {
375  QString function = QLatin1String("QSharedMemory::detach");
376  switch (errno) {
377  case EINVAL:
378  errorString = QSharedMemory::tr("%1: not attached").arg(function);
380  break;
381  default:
382  setErrorString(function);
383  }
384  return false;
385  }
386  memory = 0;
387  size = 0;
388 
389  // Get the number of current attachments
390  int id = shmget(unix_key, 0, 0400);
391  cleanHandle();
392 
393  struct shmid_ds shmid_ds;
394  if (0 != shmctl(id, IPC_STAT, &shmid_ds)) {
395  switch (errno) {
396  case EINVAL:
397  return true;
398  default:
399  return false;
400  }
401  }
402  // If there are no attachments then remove it.
403  if (shmid_ds.shm_nattch == 0) {
404  // mark for removal
405  if (-1 == shmctl(id, IPC_RMID, &shmid_ds)) {
406  setErrorString(QLatin1String("QSharedMemory::detach"));
407  switch (errno) {
408  case EINVAL:
409  return true;
410  default:
411  return false;
412  }
413  }
414 
415  // remove file
416  if (!QFile::remove(nativeKey))
417  return false;
418  }
419 #else
420  // detach from the memory segment
421  if (munmap(memory, size) == -1) {
422  setErrorString(QLatin1String("QSharedMemory::detach (munmap)"));
423  return false;
424  }
425  memory = 0;
426  size = 0;
427 
428  // get the number of current attachments
429  int shm_nattch = 0;
430  QT_STATBUF st;
431  if (QT_FSTAT(hand, &st) == 0) {
432  // subtract 2 from linkcount: one for our own open and one for the dir entry
433  shm_nattch = st.st_nlink - 2;
434  }
435  cleanHandle();
436  // if there are no attachments then unlink the shared memory
437  if (shm_nattch == 0) {
439  if (shm_unlink(shmName.constData()) == -1 && errno != ENOENT)
440  setErrorString(QLatin1String("QSharedMemory::detach (shm_unlink)"));
441  }
442 #endif // QT_POSIX_IPC
443 
444  return true;
445 }
QSharedMemory::SharedMemoryError error
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void setErrorString(const QString &function)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
#define st(var, type, card)
bool remove()
Removes the file specified by fileName().
Definition: qfile.cpp:715
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528
static QString makePlatformSafeKey(const QString &key, const QString &prefix=QLatin1String("qipc_sharedmemory_"))
Generate a string from the key which can be any unicode string into the subset that the win/unix kern...
int errno

◆ handle()

HANDLE QSharedMemoryPrivate::handle ( )

If not already made create the handle used for accessing the shared memory.

Warning
This function is not part of the public interface.

Definition at line 133 of file qsharedmemory_unix.cpp.

Referenced by create().

134 {
135  // already made
136  if (unix_key)
137  return unix_key;
138 
139  // don't allow making handles on empty keys
140  if (nativeKey.isEmpty()) {
141  errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle"));
143  return 0;
144  }
145 
146  // ftok requires that an actual file exists somewhere
147  if (!QFile::exists(nativeKey)) {
148  errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg(QLatin1String("QSharedMemory::handle"));
150  return 0;
151  }
152 
153  unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q');
154  if (-1 == unix_key) {
155  errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle"));
157  unix_key = 0;
158  }
159  return unix_key;
160 }
QSharedMemory::SharedMemoryError error
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528

◆ initKey()

bool QSharedMemoryPrivate::initKey ( )

Definition at line 271 of file qsharedmemory.cpp.

272 {
273  cleanHandle();
274 
275 #ifndef QT_NO_SYSTEMSEMAPHORE
279  QString function = QLatin1String("QSharedMemoryPrivate::initKey");
280  errorString = QSharedMemory::tr("%1: unable to set key on lock").arg(function);
281  switch(systemSemaphore.error()) {
284  break;
287  break;
290  break;
293  break;
296  break;
298  default:
300  break;
301  }
302  return false;
303  }
304 #endif
305  errorString.clear();
307  return true;
308 }
QSharedMemory::SharedMemoryError error
QSystemSemaphore systemSemaphore
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
SystemSemaphoreError error() const
Returns a value indicating whether an error occurred, and, if so, which error it was.
void setKey(const QString &key, int initialValue=0, AccessMode mode=Open)
This function works the same as the constructor.

◆ makePlatformSafeKey()

QString QSharedMemoryPrivate::makePlatformSafeKey ( const QString key,
const QString prefix = QLatin1String("qipc_sharedmemory_") 
)
static

Generate a string from the key which can be any unicode string into the subset that the win/unix kernel allows.

Warning
This function is not part of the public interface.

On Unix this will be a file name On Symbian key will be truncated to 80 characters

Definition at line 68 of file qsharedmemory.cpp.

Referenced by attach(), create(), detach(), handle(), and QSystemSemaphorePrivate::makeKeyFileName().

70 {
71  if (key.isEmpty())
72  return QString();
73 
74  QString result = prefix;
75 
76  QString part1 = key;
77  part1.replace(QRegExp(QLatin1String("[^A-Za-z]")), QString());
78  result.append(part1);
79 
81  result.append(QLatin1String(hex));
82 #ifdef Q_OS_WIN
83  return result;
84 #elif defined(Q_OS_SYMBIAN)
85  return result.left(KMaxKernelName);
86 #elif defined(QT_POSIX_IPC)
87  return QLatin1Char('/') + result;
88 #else
89  return QDir::tempPath() + QLatin1Char('/') + result;
90 #endif
91 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT QTextStream & hex(QTextStream &s)
static char toHex(quint8 c)
Definition: qurl.cpp:4440
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString tempPath()
Returns the absolute path of the system&#39;s temporary directory.
Definition: qdir.cpp:1987
QString & append(QChar c)
Definition: qstring.cpp:1777
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static QByteArray hash(const QByteArray &data, Algorithm method)
Returns the hash of data using method.

◆ setErrorString()

void QSharedMemoryPrivate::setErrorString ( const QString function)

Definition at line 85 of file qsharedmemory_unix.cpp.

Referenced by attach(), create(), and detach().

86 {
87  // EINVAL is handled in functions so they can give better error strings
88  switch (errno) {
89  case EACCES:
90  case EPERM:
91  errorString = QSharedMemory::tr("%1: permission denied").arg(function);
93  break;
94  case EEXIST:
95  errorString = QSharedMemory::tr("%1: already exists").arg(function);
97  break;
98  case ENOENT:
99  errorString = QSharedMemory::tr("%1: doesn't exist").arg(function);
101  break;
102  case EAGAIN:
103  case EMFILE:
104  case ENFILE:
105  case ENOMEM:
106  case ENOSPC:
107  errorString = QSharedMemory::tr("%1: out of resources").arg(function);
109  break;
110  case EOVERFLOW:
111  errorString = QSharedMemory::tr("%1: invalid size").arg(function);
113  break;
114  default:
115  errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(errno);
117 #ifdef QSHAREDMEMORY_DEBUG
118  qDebug() << errorString << "key" << key << "errno" << errno << EINVAL;
119 #endif
120  break;
121  }
122 }
QSharedMemory::SharedMemoryError error
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
Q_CORE_EXPORT void qDebug(const char *,...)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
int errno

◆ tryLocker()

bool QSharedMemoryPrivate::tryLocker ( QSharedMemoryLocker locker,
const QString function 
)
inline

Definition at line 156 of file qsharedmemory_p.h.

156  {
157  if (!locker->lock()) {
158  errorString = QSharedMemory::tr("%1: unable to lock").arg(function);
160  return false;
161  }
162  return true;
163  }
QSharedMemory::SharedMemoryError error
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186

Properties

◆ error

QSharedMemory::SharedMemoryError QSharedMemoryPrivate::error

Definition at line 126 of file qsharedmemory_p.h.

Referenced by attach(), create(), detach(), handle(), and setErrorString().

◆ errorString

QString QSharedMemoryPrivate::errorString

Definition at line 127 of file qsharedmemory_p.h.

Referenced by attach(), create(), detach(), handle(), and setErrorString().

◆ hand

HANDLE QSharedMemoryPrivate::hand
private

Definition at line 168 of file qsharedmemory_p.h.

Referenced by attach(), cleanHandle(), and detach().

◆ key

QString QSharedMemoryPrivate::key

Definition at line 124 of file qsharedmemory_p.h.

Referenced by attach(), create(), detach(), handle(), makePlatformSafeKey(), and setErrorString().

◆ lockedByMe

bool QSharedMemoryPrivate::lockedByMe

Definition at line 130 of file qsharedmemory_p.h.

◆ memory

void* QSharedMemoryPrivate::memory

Definition at line 122 of file qsharedmemory_p.h.

Referenced by attach(), and detach().

◆ nativeKey

QString QSharedMemoryPrivate::nativeKey

Definition at line 125 of file qsharedmemory_p.h.

Referenced by create(), detach(), and handle().

◆ size

int QSharedMemoryPrivate::size

Definition at line 123 of file qsharedmemory_p.h.

Referenced by attach(), and detach().

◆ systemSemaphore

QSystemSemaphore QSharedMemoryPrivate::systemSemaphore

Definition at line 129 of file qsharedmemory_p.h.


The documentation for this class was generated from the following files: