Bug 969 - Pane position is centered when opening files via -i or doubleclick.
Summary: Pane position is centered when opening files via -i or doubleclick.
Status: RESOLVED FIXED
Alias: None
Product: PulseView
Classification: Unclassified
Component: UI (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-06 01:38 CEST by Uwe Hermann
Modified: 2017-06-07 00:08 CEST (History)
1 user (show)



Attachments
pane centered (22.74 KB, image/png)
2017-06-06 01:38 CEST, Uwe Hermann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Hermann 2017-06-06 01:38:28 CEST
How to reproduce:

 - pulseview -i wii_nunchuk_data_bottom.sr (or any other .sr file)
 - Pane position should not be centered. See screenshot.
Comment 1 Uwe Hermann 2017-06-06 01:38:56 CEST
Created attachment 310 [details]
pane centered
Comment 2 Soeren Apel 2017-06-06 07:45:00 CEST
Yeah, that's one of the really shitty parts of Qt. It bit me more than once before and the workarounds are never pretty.

The thing is that some of the features rely on the widgets having an actual size, e.g. if I assign two widgets to a QSplitter and read back the sizes of the widgets via QSplitter::sizes(), I expect the values to reflect reality. However, because the showEvent() didn't come yet, the geometry of the splitter and the other widgets hasn't been set yet by the layouts. This means in this particular case:

- the View instance was just created and isn't visible yet
- the Session is adding at least one Signal via View::add_signal()
- View::signals_changed() sees that there is a new Signal and calls expand_header_to_fit()
- expand_header_to_fit() re-calculates the pane sizes by using the values provided by QSplitter::sizes()
- QSplitter::sizes() returns (0, 0) because the widget wasn't shown yet
- expand_header_to_fit() sets an invalid value which leads to the QSplitter defaulting to splitting the space 50:50
- expand_header_to_fit() is never called again until the user a) adds a Signal/PD or b) moves the splitter handle

An easy workaround is to set a QTimer in one-shot mode in case the size was (0, 0) but that's ugly as heck. A better solution would be to implement View::showEvent() and let it call expand_header_to_fit() in case it didn't succeed before. Still ugly, though.

Proper solution? Only perform such things after showEvent() was called but that would require major changes to the rest of the application logic since a call to a function is suddenly no longer guaranteed to succeed since it may simply request to be called again later.

Like I said, one of the shitty parts of Qt, unfortunately.
Comment 3 Uwe Hermann 2017-06-07 00:08:19 CEST
Fixed via workaround in 2a9fcd6212fd54d9589717670824d6bd020c694a, thanks!