<table><tr><td style="">tobiasdeiminger added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D15347">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D15347#495392" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D15347#495392</a>, <a href="https://phabricator.kde.org/p/sander/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@sander</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><p>Agreed. I think the first step should be to write a unit test that triggers <a href="https://bugs.kde.org/show_bug.cgi?id=409638" class="remarkup-link" target="_blank" rel="noreferrer">https://bugs.kde.org/show_bug.cgi?id=409638</a>. That way we get a reproducible way to trigger the problem even for people without a stylus.</p></div>
</blockquote>
<p>How about this test? We can reproduce a second QInputDialog by using a simple mouse click event. In bug 409638 it's probably a <tt style="background: #ebebeb; font-size: 13px;">TabletEnterProximity</tt> event instead. We could change the test accordingly to be closer to the bug report.</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">void PartTest::testInlineNoteInputDialog()
{
QInputDialog *goodInputDialog { nullptr };
QInputDialog *spuriousInputDialog { nullptr };
QScopedPointer<CloseDialogHelper> closeDialogHelper;
Okular::Part part { nullptr, nullptr, QVariantList() };
part.openUrl(QUrl::fromLocalFile(QStringLiteral(KDESRCDIR "data/file1.pdf")));
part.widget()->show();
QVERIFY( QTest::qWaitForWindowExposed(part.widget()) );
const int width = part.m_pageView->horizontalScrollBar()->maximum() +
part.m_pageView->viewport()->width();
const int height = part.m_pageView->verticalScrollBar()->maximum() +
part.m_pageView->viewport()->height();
part.m_document->setViewportPage( 0 );
// Open annotation toolbar and get the inline note tool button.
QMetaObject::invokeMethod(part.m_pageView, "slotToggleAnnotator", Q_ARG( bool, true ));
QList<QToolButton*> toolbuttonList = part.m_pageView->findChildren<QToolButton *>();
QList<QToolButton*>::iterator it = std::find_if( toolbuttonList.begin(), toolbuttonList.end(), [](const QToolButton * x) -> bool {
if (x->toolTip().contains("Inline Note") )
return true;
return false;
} );
QVERIFY(it != toolbuttonList.end());
// Clicking the tool button constructs a PickPointEngine in PageViewAnnotator,
// but doesn't use it yet.
QToolButton* inlineNoteButton = *it;
inlineNoteButton->click();
QTest::mouseMove( part.m_pageView->viewport(), QPoint(width * 0.5, height * 0.2) );
// Before we click into the viewport to finally open the input dialog,
// we schedule a function to immediately close the dialog again.
QTimer::singleShot( 0, this, [this, &goodInputDialog, &spuriousInputDialog]() {
// this lambda gets processed by the local event loop of the upcoming QInputDialog
goodInputDialog = dynamic_cast<QInputDialog*>( QApplication::activeModalWidget() );
QVERIFY( goodInputDialog );
QDialogButtonBox *buttonBox = goodInputDialog->findChild<QDialogButtonBox*>();
buttonBox->button( QDialogButtonBox::Ok )->click();
QTimer::singleShot( 0, this, [&goodInputDialog, &spuriousInputDialog]() {
// This nested lambda is called by the local event loop of the spurious input dialog (I guess?).
// But we shouldn't find another QInputDialog at all. If we do, it's a bug.
spuriousInputDialog = dynamic_cast<QInputDialog*>( QApplication::activeModalWidget() );
QVERIFY2( !spuriousInputDialog, QString("New spurious QInputDialog (0x%1) found after closing the previous QInputDialog (0x%2)")
.arg((quintptr)spuriousInputDialog, QT_POINTER_SIZE * 2, 16, QChar('0'))
.arg((quintptr)goodInputDialog, QT_POINTER_SIZE * 2, 16, QChar('0')).toUtf8().constData() );
// the test hangs here, how to close gracefully?
} );
} );
// Now actually cause the event to spawn the input dialog. We could also try tablet events here.
QTest::mouseClick( part.m_pageView->viewport(), Qt::LeftButton, Qt::NoModifier, QPoint(width * 0.5, height * 0.2) );
QVERIFY( goodInputDialog );
QVERIFY( !spuriousInputDialog );
}</pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R223 Okular</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D15347">https://phabricator.kde.org/D15347</a></div></div><br /><div><strong>To: </strong>tobiasdeiminger<br /><strong>Cc: </strong>sander, aacid, okular-devel, maguirre, fbampaloukas, joaonetto, kezik, tfella, ngraham, darcyshen<br /></div>