{"action":"created","issue":{"url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/issues/856","repository_url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser","labels_url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/issues/856/labels{/name}","comments_url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/issues/856/comments","events_url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/issues/856/events","html_url":"https://github.com/sqlitebrowser/sqlitebrowser/issues/856","id":187005260,"number":856,"title":"Hangs when selecting all the records and deleting them","user":{"login":"revolter","id":5748627,"avatar_url":"https://avatars.githubusercontent.com/u/5748627?v=3","gravatar_id":"","url":"https://api.github.com/users/revolter","html_url":"https://github.com/revolter","followers_url":"https://api.github.com/users/revolter/followers","following_url":"https://api.github.com/users/revolter/following{/other_user}","gists_url":"https://api.github.com/users/revolter/gists{/gist_id}","starred_url":"https://api.github.com/users/revolter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/revolter/subscriptions","organizations_url":"https://api.github.com/users/revolter/orgs","repos_url":"https://api.github.com/users/revolter/repos","events_url":"https://api.github.com/users/revolter/events{/privacy}","received_events_url":"https://api.github.com/users/revolter/received_events","type":"User","site_admin":false},"labels":[{"id":96964808,"url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/labels/bug","name":"bug","color":"fc2929","default":true},{"id":237840588,"url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/labels/osx","name":"osx","color":"fad8c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-03T09:01:06Z","updated_at":"2016-11-04T23:51:59Z","closed_at":null,"body":"### Details for the issue\r\n\r\n<!--\r\n\r\nThanks for coming here to report an issue. :)\r\n\r\nPlease describe it in this section, fill out the correct check boxes\r\nbelow with an \"x\", then click the \"Submit new issue\" button at the bottom\r\n\r\n-->\r\n\r\nWhen I select all the records in a big (~ 4000) table with <kbd>cmd</kbd> + <kbd>a</kbd> and hit the `Delete Record` (which should say `Delete Records` to be clear that it would delete multiple records) button, DB4S hangs for quite some time.\r\n\r\nFirstly, if it really takes this long, it should show a progress bar.\r\nSecondly, it would make sense to run `DELETE FROM table` if we notice that the user selected all the records, which would run very fast, instead of running one `DELETE` per record.\r\nAlso, wouldn't a transaction help?\r\n\r\n### Useful extra information\r\n\r\n<!-- The info below often helps, please fill it out if you're able to. :) -->\r\n\r\n#### I'm opening this issue because:\r\n\r\n- [ ] DB4S is crashing\r\n- [x] DB4S has a bug\r\n- [ ] DB4S needs a feature\r\n- [ ] DB4S has another problem\r\n\r\n#### I'm using DB4S on:\r\n\r\n- [ ] Windows: ( _version:_ ___ )\r\n- [ ] Linux: ( _distro:_ ___ )\r\n- [x] Mac OS: ( _version:_ ___ )\r\n- [ ] Other: ___\r\n\r\n#### I'm using DB4S version:\r\n\r\n- [x] 3.9.1\r\n- [ ] 3.9.0\r\n- [ ] Other: ___\r\n\r\n#### I have also:\r\n\r\n- [ ] Tried out the nightly version: https://github.com/sqlitebrowser/sqlitebrowser#windows\r\n- [ ] Searched for an existing similar issue: https://github.com/sqlitebrowser/sqlitebrowser/issues?utf8=%E2%9C%93&q=is%3Aissue%20\r\n"},"comment":{"url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/issues/comments/258574596","html_url":"https://github.com/sqlitebrowser/sqlitebrowser/issues/856#issuecomment-258574596","issue_url":"https://api.github.com/repos/sqlitebrowser/sqlitebrowser/issues/856","id":258574596,"user":{"login":"prutz1311","id":6525383,"avatar_url":"https://avatars.githubusercontent.com/u/6525383?v=3","gravatar_id":"","url":"https://api.github.com/users/prutz1311","html_url":"https://github.com/prutz1311","followers_url":"https://api.github.com/users/prutz1311/followers","following_url":"https://api.github.com/users/prutz1311/following{/other_user}","gists_url":"https://api.github.com/users/prutz1311/gists{/gist_id}","starred_url":"https://api.github.com/users/prutz1311/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prutz1311/subscriptions","organizations_url":"https://api.github.com/users/prutz1311/orgs","repos_url":"https://api.github.com/users/prutz1311/repos","events_url":"https://api.github.com/users/prutz1311/events{/privacy}","received_events_url":"https://api.github.com/users/prutz1311/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T23:51:59Z","updated_at":"2016-11-04T23:51:59Z","body":"It turns out that the method `removeRow` of `SqliteTableModel` object gets invoked [here](https://github.com/sqlitebrowser/sqlitebrowser/blob/982e4c4d346e066b72e8a8df2d47fa00c0075269/src/MainWindow.cpp#L589), and since [`SqliteTableModel`](https://github.com/sqlitebrowser/sqlitebrowser/blob/982e4c4d346e066b72e8a8df2d47fa00c0075269/src/sqlitetablemodel.h#L11) is a subclass of [`QAbstractTableModel`](https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/corelib/kernel/qabstractitemmodel.h#L345) which is, in turn, a subclass of `QAbstractItemModel`, the following code from Qt library is executed:\r\n```c++\r\ninline bool QAbstractItemModel::removeRow(int arow, const QModelIndex &aparent)\r\n{ return removeRows(arow, 1, aparent); }\r\n```\r\nthat is, it forces us to have only 1 row deleted.\r\nMy backtrace on deletion looks like this:\r\n```gdb\r\n(gdb) backtrace\r\n#0  DBBrowserDB::deleteRecord (this=0xba25c8, table=..., rowid=...)\r\n    at /home/oleg/Документы/программирование/Sources/sqlitebrowser/src/sqlitedb.cpp:870\r\n#1  0x00000000005ee5cf in SqliteTableModel::removeRows (this=0xb949d0, row=40, count=1, parent=...)\r\n    at /home/oleg/Документы/программирование/Sources/sqlitebrowser/src/sqlitetablemodel.cpp:415\r\n#2  0x00000000005a3a98 in QAbstractItemModel::removeRow (this=0xb949d0, arow=40, aparent=...)\r\n    at /opt/qt57/include/QtCore/qabstractitemmodel.h:347\r\n#3  0x000000000058fe72 in MainWindow::deleteRecord (this=0xba24a0)\r\n    at /home/oleg/Документы/программирование/Sources/sqlitebrowser/src/MainWindow.cpp:589\r\n#4  0x0000000000649bff in MainWindow::qt_static_metacall (_o=0xba24a0, _c=QMetaObject::InvokeMetaMethod, _id=17, _a=0x7fffffffd550)\r\n    at /home/oleg/Документы/программирование/Sources/sqlitebrowser/build/moc_MainWindow.cpp:438\r\n#5  0x00007ffff6cfc9d5 in QMetaObject::activate(QObject*, int, int, void**) () from /opt/qt57/lib/libQt5Core.so.5\r\n#6  0x00007ffff7473f52 in QAbstractButton::clicked(bool) () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#7  0x00007ffff747414a in ?? () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#8  0x00007ffff7475648 in ?? () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#9  0x00007ffff74757c4 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#10 0x00007ffff73d85da in QWidget::event(QEvent*) () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#11 0x00007ffff7394cbc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#12 0x00007ffff739c61b in QApplication::notify(QObject*, QEvent*) () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#13 0x00007ffff6cd48e5 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/qt57/lib/libQt5Core.so.5\r\n#14 0x00007ffff739b0a3 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool)\r\n    () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#15 0x00007ffff73f14e1 in ?? () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#16 0x00007ffff73f3933 in ?? () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#17 0x00007ffff7394cbc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#18 0x00007ffff739bc40 in QApplication::notify(QObject*, QEvent*) () from /opt/qt57/lib/libQt5Widgets.so.5\r\n#19 0x00007ffff6cd48e5 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /opt/qt57/lib/libQt5Core.so.5\r\n#20 0x00007ffff798319b in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) ()\r\n   from /opt/qt57/lib/libQt5Gui.so.5\r\n#21 0x00007ffff7984cf5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()\r\n   from /opt/qt57/lib/libQt5Gui.so.5\r\n#22 0x00007ffff7966dab in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()\r\n   from /opt/qt57/lib/libQt5Gui.so.5\r\n#23 0x00007fffef8b13f0 in ?? () from /opt/qt57/plugins/platforms/../../lib/libQt5XcbQpa.so.5\r\n#24 0x00007ffff4755e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0\r\n#25 0x00007ffff4756048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0\r\n#26 0x00007ffff47560ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0\r\n#27 0x00007ffff6d2329c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/qt57/lib/libQt5Core.so.5\r\n#28 0x00007ffff6cd2bbb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /opt/qt57/lib/libQt5Core.so.5\r\n#29 0x00007ffff6cda9b6 in QCoreApplication::exec() () from /opt/qt57/lib/libQt5Core.so.5\r\n#30 0x0000000000634f58 in main (argc=2, argv=0x7fffffffe3b8)\r\n    at /home/oleg/Документы/программирование/Sources/sqlitebrowser/src/main.cpp:13\r\n(gdb) \r\n```\r\nIt seems to me that we cannot delete multiple records at once if we rely on table model of Qt."}}
{"actor":{"display_login":"prutz1311"}}