Bug 427569

Summary: Thumbnail view pops out as new window on Qt 5.15
Product: [Applications] gwenview Reporter: Yichao Yu <yyc1992>
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: drokergeek, nate, postix
Priority: NOR    
Version: 20.08.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 20.08.3
Sentry Crash Report:

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