krakjoe / ui

Cross platform UI development in PHP
Other
518 stars 39 forks source link

[bug] Combo setSelected < 0 causes SIGABRT #49

Closed dmvdbrugge closed 1 year ago

dmvdbrugge commented 6 years ago

What you do:

$combo = new Combo(); $combo->setSelected(-5);

What you expect Either InvalidArgumentException, or selected becomes -1 (same as $combo->setSelected(5)).

What happens On OSX, libui throws NSException, causing SIGABRT

dmvdbrugge@macbook:~/dynamic-components (master) $ php -a
Interactive shell

php > $combo = new UI\Controls\Combo();
php > $combo->setSelected(5);
php > var_dump($combo->getSelected());
int(-1)
php > $combo->setSelected(-5);
2018-06-19 10:11:00.038 php[72092:3074400] *** Assertion failure in -[NSMenu itemAtIndex:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.40.112/Menus.subproj/NSMenu.m:967
2018-06-19 10:11:00.041 php[72092:3074400] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: index >= 0'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff471c032b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x00007fff6e32ec76 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff471c60c2 +[NSException raise:format:arguments:] + 98
        3   Foundation                          0x00007fff492ef340 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
        4   AppKit                              0x00007fff446c50a4 -[NSMenu itemAtIndex:] + 216
        5   AppKit                              0x00007fff44762ef6 -[NSPopUpButtonCell _selectItemAtIndex:alteringState:] + 270
        6   libui.A.dylib                       0x000000010570c02a uiComboboxSetSelected + 42
        7   ui.so                               0x00000001056d2227 zim_Combo_setSelected + 55
        8   php                                 0x0000000102b06105 ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER + 607
        9   php                                 0x0000000102af0e06 execute_ex + 98
        10  php                                 0x0000000102af1058 zend_execute + 532
        11  php                                 0x0000000102aa7387 zend_eval_stringl + 444
        12  php                                 0x000000010294d1f9 readline_shell_run + 2480
        13  php                                 0x0000000102b4e0f1 do_cli + 2755
        14  php                                 0x0000000102b4d4be main + 1180
        15  libdyld.dylib                       0x00007fff6ef48015 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
dmvdbrugge commented 1 year ago

Closing to clean up my stuff and this repo is dead anyway.