Bug 427569 - Thumbnail view pops out as new window on Qt 5.15
Summary: Thumbnail view pops out as new window on Qt 5.15
Status: RESOLVED FIXED
Alias: None
Product: gwenview
Classification: Applications
Component: general (show other bugs)
Version: 20.08.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Gwenview Bugs
URL:
Keywords:
: 418612 421005 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-10-12 05:28 UTC by Yichao Yu
Modified: 2020-10-13 00:22 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.08.3
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yichao Yu 2020-10-12 05:28:10 UTC
SUMMARY
When openning some images (seems to mainly affect JPG) if the thumbnail bar is set to be enabled by default, it'll pop up as a new window instead of embedded in the main one. Closing it and reopenning it cause the issue to go away.

I believe this is a new issue and wasn't there a few months ago.
Testing a commit from Jan 2020 still shows the issue so I think it's likely to be caused by upgrading to qt 5.15. It's quite hard for me to downgrade qt for testing though I may try to compile a debug version...

STEPS TO REPRODUCE
1. Open a jpg image

OBSERVED RESULT
Thumbnail view bar pops up as new window.

EXPECTED RESULT
It shouldn't be

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: ArchLinux x86_64
KDE Plasma Version: 5.19.5
KDE Frameworks Version: 5.74.0
Qt Version: 5.15.1

ADDITIONAL INFORMATION
Comment 1 Yichao Yu 2020-10-12 07:07:25 UTC
I'm still not sure what's changed but the issue seems to be caused by showing a widget before a parent is set.

In `app/viewmainpage.cpp`, `mThumbnailBar` was created without a parent and may be set to visible immediately after creation before it is added to `mThumbnailSplitter`. This caused a toplevel `QXcbWindow` to be created for it.

The following patch fixes/works around the issue.

```
diff --git a/app/viewmainpage.cpp b/app/viewmainpage.cpp
index 35c5ce59..d1faa431 100644
--- a/app/viewmainpage.cpp
+++ b/app/viewmainpage.cpp
@@ -148,7 +148,6 @@ struct ViewMainPagePrivate
         mThumbnailBar = new ThumbnailBarView;
         ThumbnailBarItemDelegate* delegate = new ThumbnailBarItemDelegate(mThumbnailBar);
         mThumbnailBar->setItemDelegate(delegate);
-        mThumbnailBar->setVisible(GwenviewConfig::thumbnailBarIsVisible());
         mThumbnailBar->setSelectionMode(QAbstractItemView::ExtendedSelection);
     }

@@ -330,6 +329,7 @@ struct ViewMainPagePrivate
         mThumbnailSplitter->addWidget(mAdapterContainer);
         mThumbnailSplitter->addWidget(mThumbnailBar);
         mThumbnailSplitter->setSizes(GwenviewConfig::thumbnailSplitterSizes());
+        mThumbnailBar->setVisible(GwenviewConfig::thumbnailBarIsVisible());

         QVBoxLayout* layout = new QVBoxLayout(q);
         layout->setContentsMargins(0, 0, 0, 0);
```

This seems to be fairly harmless. I'm not sure though if this is supposed to be working.
Comment 2 Yichao Yu 2020-10-12 07:11:53 UTC
Ref https://bugreports.qt.io/browse/QTBUG-87345
Comment 3 Bug Janitor Service 2020-10-12 23:11:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/gwenview/-/merge_requests/17
Comment 4 Yichao Yu 2020-10-12 23:12:55 UTC
I've reduced the test case in the Qt bug report so I'm fairly sure it's a Qt bug now. https://bugreports.qt.io/browse/QTBUG-87345?focusedCommentId=530782&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-530782

Also submitted https://invent.kde.org/graphics/gwenview/-/merge_requests/17 as a workaround as well as general improvement...
Comment 5 Nate Graham 2020-10-12 23:47:03 UTC
*** Bug 421005 has been marked as a duplicate of this bug. ***
Comment 6 Nate Graham 2020-10-12 23:47:06 UTC
*** Bug 418612 has been marked as a duplicate of this bug. ***
Comment 7 Yichao Yu 2020-10-13 00:21:04 UTC
Git commit e737554c9faff3be27083497c26675155bcf8122 by Yichao Yu.
Committed on 13/10/2020 at 00:19.
Pushed by ngraham into branch 'release/20.08'.

Set visibility after setting parent

This avoids recreating native window, which should be generally good,
and works around QTBUG-87345.

M  +3    -1    app/viewmainpage.cpp

https://invent.kde.org/graphics/gwenview/commit/e737554c9faff3be27083497c26675155bcf8122