OpenBoard-org / OpenBoard

OpenBoard is a cross-platform interactive whiteboard application intended for use in a classroom setting.
https://openboard.ch/
GNU General Public License v3.0
2.35k stars 423 forks source link

Fix crash deleting scene with media item #1119

Open letsfindaway opened 4 hours ago

letsfindaway commented 4 hours ago

This PR fixes two crashes in two commits.

Crash when deleting a scene with a video item

The first one is a crash occurring with Qt 6 when a scene containing a video item is deleted.

This sequence lead to the crash in Qt 6. In Qt 5 a quite similar sequence was executed, but for some reason this did not result in a crash.

Analyzing the code I found out that the complete destructor of UBGraphicsMediaItem was not necessary:

So my solution is to completely remove the code from that destructor.

Crash when dragging an arbitrary object to the board thumbnail palette

During my tests I discovered another crash. I accidentally dragged an object from the library palette to the thumbnail palette. As soon as the mouse is over the palette, OpenBoard crashed.

The thumbnail palette implements Drag-and-drop to allow reordering of pages. If you long click on a page, then you initiate a DnD operation and can drop the page at another place. There is no code which would handle dragging any other object to the palette.

In the code the starting point for the DnD operation is UBBoardThumbnailsView::dragEnterEvent which is invoked, when the cursor first enters the drop target area. Here it is decided, whether an object can be dropped on this target. The code here first checked whether the source area is the same as the target area. This is the case when dragging pages within the thumbnail palette. If this is the case, then a move operation is initiated.

In all other cases however the code simply accepted any proposed action. It was however not prepared to process that later, which lead to the crash.

The problem is solved by removing that code accepting the drop of foreign objects.

This is my first PR which solves two severe problems by just removing some lines of code ;-)