本文整理汇总了C++中QWeakPointer::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QWeakPointer::isNull方法的具体用法?C++ QWeakPointer::isNull怎么用?C++ QWeakPointer::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWeakPointer
的用法示例。
在下文中一共展示了QWeakPointer::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onHeadersComplete
int onHeadersComplete(http_parser *parser)
{
TcpSocket *socket = static_cast<TcpSocket*>(parser->data);
#ifndef NO_LOG
sLog(LogEndpoint::LogLevel::DEBUG) << " === parsed header ====";
const QHash<QString, QSharedPointer<QString>> &headers = socket->getHeader().getHeaderInfo();
QHash<QString, QSharedPointer<QString>>::const_iterator i = headers.constBegin();
while (i != headers.constEnd())
{
sLog(LogEndpoint::LogLevel::DEBUG) << i.key() << *(i.value().data());
++i;
}
sLog(LogEndpoint::LogLevel::DEBUG) << " === ============= ====";
sLogFlush();
#endif
QWeakPointer<QString> host = socket->getHeader().getHeaderInfo("Host");
if (!host.isNull())
{
socket->getHeader().setHost(*host.data());
}
return 0;
}
示例2: switch
// The access function for guarded QObject pointers.
static void *qpointer_access_func(sipSimpleWrapper *w, AccessFuncOp op)
{
#if QT_VERSION >= 0x040500
QWeakPointer<QObject> *guard = reinterpret_cast<QWeakPointer<QObject> *>(w->data);
#else
QObjectGuard *guard = reinterpret_cast<QObjectGuard *>(w->data);
#endif
void *addr;
switch (op)
{
case UnguardedPointer:
#if QT_VERSION >= 0x040500
addr = guard->data();
#else
addr = guard->unguarded;
#endif
break;
case GuardedPointer:
#if QT_VERSION >= 0x040500
addr = guard->isNull() ? 0 : guard->data();
#else
addr = (QObject *)guard->guarded;
#endif
break;
case ReleaseGuard:
delete guard;
addr = 0;
break;
}
return addr;
}
示例3: sender
void
MetaQueryWidget::populateComboBox( QStringList results )
{
QObject* query = sender();
if( !query )
return;
QWeakPointer<KComboBox> combo = m_runningQueries.value(query);
if( combo.isNull() )
return;
// note: adding items seems to reset the edit text, so we have
// to take care of that.
disconnect( combo.data(), 0, this, 0 );
// want the results unique and sorted
const QSet<QString> dataSet = results.toSet();
QStringList dataList = dataSet.toList();
dataList.sort();
combo.data()->addItems( dataList );
KCompletion* comp = combo.data()->completionObject();
comp->setItems( dataList );
// reset the text and re-enable the signal
combo.data()->setEditText( m_filter.value );
connect( combo.data(), SIGNAL(editTextChanged( const QString& ) ),
SLOT(valueChanged(const QString&)) );
}
示例4:
QNetworkAccessManager*
nam()
{
if ( s_nam.isNull() )
return 0;
return s_nam.data();
}
示例5: saveReport
//static
void DrKonqi::saveReport(const QString & reportText, QWidget *parent)
{
if (KCmdLineArgs::parsedArgs()->isSet("safer")) {
KTemporaryFile tf;
tf.setSuffix(".kcrash.txt");
tf.setAutoRemove(false);
if (tf.open()) {
QTextStream textStream(&tf);
textStream << reportText;
textStream.flush();
KMessageBox::information(parent, i18nc("@info",
"Report saved to <filename>%1</filename>.",
tf.fileName()));
} else {
KMessageBox::sorry(parent, i18nc("@info","Could not create a file in which to save the report."));
}
} else {
QString defname = getSuggestedKCrashFilename(crashedApplication());
QWeakPointer<KFileDialog> dlg = new KFileDialog(defname, QString(), parent);
dlg.data()->setSelection(defname);
dlg.data()->setCaption(i18nc("@title:window","Select Filename"));
dlg.data()->setOperationMode(KFileDialog::Saving);
dlg.data()->setMode(KFile::File);
dlg.data()->setConfirmOverwrite(true);
dlg.data()->exec();
if (dlg.isNull()) {
//Dialog is invalid, it was probably deleted (ex. via DBus call)
//return and do not crash
return;
}
KUrl fileUrl = dlg.data()->selectedUrl();
delete dlg.data();
if (fileUrl.isValid()) {
KTemporaryFile tf;
if (tf.open()) {
QTextStream ts(&tf);
ts << reportText;
ts.flush();
} else {
KMessageBox::sorry(parent, i18nc("@info","Cannot open file <filename>%1</filename> "
"for writing.", tf.fileName()));
return;
}
if (!KIO::NetAccess::upload(tf.fileName(), fileUrl, parent)) {
KMessageBox::sorry(parent, KIO::NetAccess::lastErrorString());
}
}
}
}
示例6: testCustomNavigationBarContentOwnershipOnPageDeletion
void Ut_MApplicationPage::testCustomNavigationBarContentOwnershipOnPageDeletion() {
QGraphicsWidget *customNavigationBarContent = new QGraphicsWidget;
QWeakPointer<QGraphicsWidget> customNavigationBarContentPointer = customNavigationBarContent;
m_subject->setCustomNavigationBarContent(customNavigationBarContent);
delete m_subject;
m_subject = 0;
QVERIFY(customNavigationBarContentPointer.isNull());
}
示例7: exec
int PasswordDialog::exec()
{
Q_D(PasswordDialog);
if (d->eventLoop) // recursive call
return -1;
QEventLoop eventLoop;
d->eventLoop = &eventLoop;
QWeakPointer<PasswordDialog> guard = this;
(void) eventLoop.exec();
d->eventLoop = 0;
if (guard.isNull())
return PasswordDialog::Rejected;
return result();
}
示例8: testConstructorDestructorCreate
void SimplePersonSetTest::testConstructorDestructorCreate()
{
// Create a PersonSet.
SimplePersonSetPtr personSet = SimplePersonSet::create();
QVERIFY(!personSet.isNull());
// Get a QWeakPointer to it, for testing destruction.
QWeakPointer<PersonSet> weakPtr = QWeakPointer<PersonSet>(personSet.data());
// Remove the only strong ref.
personSet.reset();
// Check the PersonSet was deleted OK
QVERIFY(personSet.isNull());
QVERIFY(weakPtr.isNull());
}
示例9: testCustomNavigationBarContentSetterAndGetter
void Ut_MApplicationPage::testCustomNavigationBarContentSetterAndGetter()
{
QGraphicsWidget *customNavigationBarContent = new QGraphicsWidget;
QWeakPointer<QGraphicsWidget> customNavigationBarContentPointer = customNavigationBarContent;
QVERIFY(m_subject->customNavigationBarContent() == 0);
m_subject->setCustomNavigationBarContent(customNavigationBarContent);
QVERIFY(m_subject->customNavigationBarContent() == customNavigationBarContent);
m_subject->setCustomNavigationBarContent(0);
QVERIFY(m_subject->customNavigationBarContent() == 0);
// Page should have deleted the old widget when replacing it with the 0 (null) one.
QVERIFY(customNavigationBarContentPointer.isNull());
}
示例10: myMessageOutput
void myMessageOutput(QtMsgType type, const char *msg)
{
QString strMsg = QString::fromLatin1(msg);
if (!QCoreApplication::closingDown()) {
if (!logger.isNull()) {
if (recursiveLock.testAndSetOrdered(0, 1)) {
QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
recursiveLock = 0;
}
} else {
warnings += strMsg;
warnings += QLatin1Char('\n');
}
}
if (systemMsgOutput) { // Windows
systemMsgOutput(type, msg);
} else { // Unix
fprintf(stderr, "%s\n", msg);
fflush(stderr);
}
}
示例11: setProblem
//public slot
void ProblemModelAdapter::setProblem(QWeakPointer<PlanningProblem> problem)
{
/*
We have to do this with the start and end markers to prevent and annoying save/load bug
where the markers disappear and reappear upong loading over and over
*/
if (!_startMarker.isNull())
{
disconnect(_startMarker.data(),
SIGNAL(destroyed()),
this,
SLOT(handleStartMarkerDestroyed()));
_startMarker->deleteLater();
_startMarker = 0;
}
_problem = problem;
if (problem.isNull())
return;
_objectToArea.clear();
PlanningProblem * raw = problem.data();
connect(raw,
SIGNAL(startPositionChanged(Position)),
this,
SLOT(handleStartPositionChanged(Position)));
connect(raw,
SIGNAL(startPositionRemoved()),
this,
SLOT(handleStartPositionRemoved()));
connect(raw,
SIGNAL(areaAdded(QSharedPointer<TaskArea>)),
this,
SLOT(handleAreaAdded(QSharedPointer<TaskArea>)));
}
示例12: switch
// The access function for guarded QObject pointers.
static void *qpointer_access_func(sipSimpleWrapper *w, AccessFuncOp op)
{
QWeakPointer<QObject> *guard = reinterpret_cast<QWeakPointer<QObject> *>(w->data);
void *addr;
switch (op)
{
case UnguardedPointer:
addr = guard->data();
break;
case GuardedPointer:
addr = guard->isNull() ? 0 : guard->data();
break;
case ReleaseGuard:
delete guard;
addr = 0;
break;
}
return addr;
}
示例13: myMessageOutput
void myMessageOutput(QtMsgType type, const char *msg)
{
QString strMsg = QString::fromLatin1(msg);
if (!QCoreApplication::closingDown()) {
if (!logger.isNull()) {
if (recursiveLock.testAndSetOrdered(0, 1)) {
QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
recursiveLock = 0;
}
} else {
warnings += strMsg;
warnings += QLatin1Char('\n');
}
}
#if defined (Q_OS_SYMBIAN)
static int fd = -1;
if (fd == -1)
fd = ::open("E:\\qml.log", O_WRONLY | O_CREAT);
::write(fd, msg, strlen(msg));
::write(fd, "\n", 1);
::fsync(fd);
switch (type) {
case QtFatalMsg:
abort();
}
#endif
if (systemMsgOutput) {
systemMsgOutput(type, msg);
} else { // Unix
fprintf(stderr, "%s\n", msg);
fflush(stderr);
}
}
示例14: removeAccount
void JabberEditAccountWidget::removeAccount()
{
QWeakPointer<QMessageBox> messageBox = new QMessageBox(this);
messageBox.data()->setWindowTitle(tr("Confirm account removal"));
messageBox.data()->setText(tr("Are you sure you want to remove account %1 (%2)?")
.arg(account().accountIdentity().name())
.arg(account().id()));
QPushButton *removeButton = messageBox.data()->addButton(tr("Remove account"), QMessageBox::AcceptRole);
messageBox.data()->addButton(QMessageBox::Cancel);
messageBox.data()->setDefaultButton(QMessageBox::Cancel);
messageBox.data()->exec();
if (messageBox.isNull())
return;
if (messageBox.data()->clickedButton() == removeButton)
{
AccountManager::instance()->removeAccountAndBuddies(account());
deleteLater();
}
delete messageBox.data();
}
示例15: onNewMessage
void InternalCoreConnection::onNewMessage(Common::MessageHeader::MessageType type, const google::protobuf::Message& message)
{
// While we are not authenticated we accept only two message types.
if (!this->authenticated && type != Common::MessageHeader::GUI_ASK_FOR_AUTHENTICATION && type != Common::MessageHeader::GUI_AUTHENTICATION_RESULT)
return;
switch (type)
{
case Common::MessageHeader::GUI_ASK_FOR_AUTHENTICATION:
{
const Protos::GUI::AskForAuthentication& askForAuthentication = static_cast<const Protos::GUI::AskForAuthentication&>(message);
Protos::GUI::Authentication authentication;
this->salt = askForAuthentication.salt();
if (!this->password.isEmpty())
this->connectionInfo.password = Common::Hasher::hashWithSalt(this->password, this->salt);
authentication.mutable_password_challenge()->set_hash(Common::Hasher::hashWithSalt(this->connectionInfo.password, askForAuthentication.salt_challenge()).getData(), Common::Hash::HASH_SIZE);
this->password.clear();
this->send(Common::MessageHeader::GUI_AUTHENTICATION, authentication);
}
break;
case Common::MessageHeader::GUI_AUTHENTICATION_RESULT:
{
const Protos::GUI::AuthenticationResult& authenticationResult = static_cast<const Protos::GUI::AuthenticationResult&>(message);
if (authenticationResult.status() == Protos::GUI::AuthenticationResult::AUTH_OK)
{
this->connectedAndAuthenticated();
}
else
{
switch (authenticationResult.status())
{
case Protos::GUI::AuthenticationResult::AUTH_PASSWORD_NOT_DEFINED:
emit connectingError(ICoreConnection::ERROR_NO_REMOTE_PASSWORD_DEFINED);
break;
case Protos::GUI::AuthenticationResult::AUTH_BAD_PASSWORD:
emit connectingError(ICoreConnection::ERROR_WRONG_PASSWORD);
break;
case Protos::GUI::AuthenticationResult::AUTH_ERROR:
emit connectingError(ICoreConnection::ERROR_UNKNOWN);
break;
default:;
}
}
}
break;
case Common::MessageHeader::GUI_STATE:
{
const Protos::GUI::State& state = static_cast<const Protos::GUI::State&>(message);
emit newState(state);
this->send(Common::MessageHeader::GUI_STATE_RESULT);
}
break;
case Common::MessageHeader::GUI_EVENT_CHAT_MESSAGES:
{
const Protos::GUI::EventChatMessages& eventChatMessages = static_cast<const Protos::GUI::EventChatMessages&>(message);
if (eventChatMessages.message_size() > 0)
emit newChatMessages(eventChatMessages);
}
break;
case Common::MessageHeader::GUI_EVENT_LOG_MESSAGE:
{
const Protos::GUI::EventLogMessage& eventLogMessage = static_cast<const Protos::GUI::EventLogMessage&>(message);
QDateTime dateTime = QDateTime::fromMSecsSinceEpoch(eventLogMessage.time());
QString message = Common::ProtoHelper::getStr(eventLogMessage, &Protos::GUI::EventLogMessage::message);
LM::Severity severity = LM::Severity(eventLogMessage.severity());
emit newLogMessage(LM::Builder::newEntry(dateTime, severity, message));
}
break;
case Common::MessageHeader::GUI_SEARCH_TAG:
{
const Protos::GUI::Tag& tagMessage = static_cast<const Protos::GUI::Tag&>(message);
while (!this->searchResultsWithoutTag.isEmpty())
{
QWeakPointer<SearchResult> searchResult = this->searchResultsWithoutTag.takeFirst();
if (!searchResult.isNull())
{
searchResult.data()->setTag(tagMessage.tag());
break;
}
}
}
break;
case Common::MessageHeader::GUI_SEARCH_RESULT:
//.........这里部分代码省略.........