Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/frame/ccentralwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,8 @@ void DrawBoard::addPage(Page *page)
fileWatcher()->addWather(page->file());

setCurrentPage(page);

page->adjustViewScaleRatio();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Page construction crashes

When a Page is constructed with a non-null DrawBoard* before its context is set, Page registers with the board before its context exists, so adjustViewScaleRatio() reaches scene() with no scene and dereferences the null result, crashing construction.

Ensure the page has a context and scene before invoking adjustViewScaleRatio(), or defer the adjustment until they exist.

Prompt for AI agents
In `src/frame/ccentralwidget.cpp` at line 881:

**Page construction crashes**

When a `Page` is constructed with a non-null `DrawBoard*` before its context is set, `Page` registers with the board before its context exists, so `adjustViewScaleRatio()` reaches `scene()` with no scene and dereferences the null result, crashing construction.

Ensure the page has a context and scene before invoking `adjustViewScaleRatio()`, or defer the adjustment until they exist.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Imported images appear too small

When an image is loaded through a path that creates a blank page before replacing its scene rect with the image bounds, addPage() scales the default screen-sized scene before the image dimensions are installed, and the later adjustViewScaleRatio() does not reset that scale; it either compounds the zoom-out or skips fitting when the image scene fits the viewport, leaving the imported image smaller than intended.

Fit the view after installing the image scene rect, setting the scale from the desired fit instead of retaining or compounding the blank page's scale.

Prompt for AI agents
In `src/frame/ccentralwidget.cpp` at line 881:

**Imported images appear too small**

When an image is loaded through a path that creates a blank page before replacing its scene rect with the image bounds, `addPage()` scales the default screen-sized scene before the image dimensions are installed, and the later `adjustViewScaleRatio()` does not reset that scale; it either compounds the zoom-out or skips fitting when the image scene fits the viewport, leaving the imported image smaller than intended.

Fit the view after installing the image scene rect, setting the scale from the desired fit instead of retaining or compounding the blank page's scale.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Hidden pages stay undersized

When a page is added before its window has been shown or its layout has established nonzero viewport dimensions, adjustViewScaleRatio() reads the not-yet-laid-out viewport dimensions, computes a zero ratio, and passes it to PageView::scale(), which clamps the scale to 0.1. The later resize and show handlers do not fit the page again, so the canvas stays at 10% instead of fitting the viewport.

Defer fitting until the viewport has valid dimensions, and retry the fit after the page is shown or resized.

Prompt for AI agents
In `src/frame/ccentralwidget.cpp` at line 881:

**Hidden pages stay undersized**

When a page is added before its window has been shown or its layout has established nonzero viewport dimensions, `adjustViewScaleRatio()` reads the not-yet-laid-out viewport dimensions, computes a zero ratio, and passes it to `PageView::scale()`, which clamps the scale to 0.1. The later resize and show handlers do not fit the page again, so the canvas stays at 10% instead of fitting the viewport.

Defer fitting until the viewport has valid dimensions, and retry the fit after the page is shown or resized.

}

bool DrawBoard::closePage(const QString &key)
Expand Down
Loading