Thiago Macieira wrote:

> On Tuesday 08 December 2015 17:14:46 René J.V. Bertin wrote:
>> Hello,
>> 
>> I'm experiencing a crash in setMainWindow() with the code below (from
>> KF5-kwidgetsaddons). Is this something that is allowed on OS X, and
>> supposed to work?
>> 
>> static QDialog *createWIdDialog(WId parent_id)
>> {
>>     QWidget *parent = QWidget::find(parent_id);
>>     QDialog *dialog = new QDialog(parent, Qt::Dialog);
>>     if (!parent && parent_id) {
>>         setMainWindow(dialog, parent_id);
>>     }
>>     return dialog;
>> }
> 
> Which line crashes and what's the backtrace of the crash?
> 

Backtrace below. I've had a look at my KDE4 library code, and saw that the 
equivalent function is a noop on OS X. I think that's partly because (at least 
with Qt4) the WId was usually not what the documentation said it was, but may 
also have to do with the fact that there are severe restrictions on finding the 
native window instance that goes with a given WId, on OS X. I think that's what 
goes on here: the crash occurs in kwalletd5 when kwalletmanager5 requests it to 
open a wallet via a DBus command. If the WId belongs to kwalletmanager5, it's 
to be expected that kwalletd5 cannot determine the corresponding native window 
instance.

So I guess that the partial answer to my question is that "it" is not expected 
to work in all conditions (or even not expected to work in general). But that 
doesn't mean the code should crash if it can be avoided in any way.

Should QWidget::find(WId) return a non-null widget for any WId "owned" by an 
application, or is there a more type-agnostic equivalent mapping function that 
works for a wider range of WId types (supposing not every WId is a widget)?

R.

* thread #1: tid = 0x77ebf2, 0x00007fff8a130091 libobjc.A.dylib`objc_msgSend + 
17, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x7fb829c79540)
    frame #0: 0x00007fff8a130091 libobjc.A.dylib`objc_msgSend + 17
    frame #1: 0x000000010e4c2889 
libqcocoa.dylib`QCocoaWindow::QCocoaWindow(QWindow*) [inlined] 
QCocoaWindow::setContentView(this=0x00007fc340f4f3c0) + 50 at 
qcocoawindow.mm:1154
    frame #2: 0x000000010e4c2857 
libqcocoa.dylib`QCocoaWindow::QCocoaWindow(this=0x00007fc340f4f3c0, 
tlw=0x00007fc340f4f730) + 903 at qcocoawindow.mm:380
  * frame #3: 0x000000010e4bdcb2 
libqcocoa.dylib`QCocoaIntegration::createPlatformWindow(this=<unavailable>, 
window=<unavailable>) const + 34 at qcocoaintegration.mm:434
    frame #4: 0x00000001090515cc 
QtGui`QWindowPrivate::create(this=0x00007fc340f4ff70, recursive=false) + 60 at 
qwindow.cpp:392
    frame #5: 0x0000000109054b3e QtGui`QWindow::fromWinId(unsigned long long) 
[inlined] QWindow::create(this=0x00007fc340f4f730) + 5 at qwindow.cpp:548
    frame #6: 0x0000000109054b39 QtGui`QWindow::fromWinId(id=140428951655744) + 
153 at qwindow.cpp:2360
    frame #7: 0x000000010843074f 
libKF5WidgetsAddons.5.dylib`KMessageBox::errorListWId(unsigned long long, 
QString const&, QStringList const&, QString const&, 
QFlags<KMessageBox::Option>) [inlined] 
KMessageBox::setMainWindow(subWidget=0x00007fc340f43c80, 
mainWindowId=140428951655744) + 28 at kmessagebox.cpp:135
    frame #8: 0x0000000108430733 
libKF5WidgetsAddons.5.dylib`KMessageBox::errorListWId(unsigned long long, 
QString const&, QStringList const&, QString const&, 
QFlags<KMessageBox::Option>) [inlined] 
KMessageBox::createWIdDialog(parent_id=<unavailable>) + 65 at 
kmessagebox.cpp:149
    frame #9: 0x00000001084306f2 
libKF5WidgetsAddons.5.dylib`KMessageBox::errorListWId(parent_id=140428951655744,
 text=0x00007fff57a4f020, strlist=0x00007fff57a4eb88, 
caption=0x00007fff57a4f010, options=<unavailable>) + 34 at kmessagebox.cpp:1108
    frame #10: 0x0000000108430639 
libKF5WidgetsAddons.5.dylib`KMessageBox::errorWId(parent_id=<unavailable>, 
text=<unavailable>, caption=<unavailable>, options=<unavailable>) + 41 at 
kmessagebox.cpp:1102
    frame #11: 0x000000010825470f 
libkwalletbackend5.5.dylib`KWallet::GpgPersistHandler::read(this=<unavailable>, 
wb=<unavailable>, sf=<unavailable>, w=140428951655744) + 319 at 
backendpersisthandler.cpp:602

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to