745e2aa4 by 柴进

处理mac打包后粘贴图片缩略图不可见的问题,处理历史history不可见问题

1 parent cf1cdc86
......@@ -2197,10 +2197,41 @@ class ImageGeneratorWindow(QMainWindow):
except Exception as e:
self.logger.error(f"创建缩略图失败: {file_path}, 错误: {str(e)}", exc_info=True)
# 强制刷新布局和滚动区域(macOS 打包环境下可能需要)
# 强制刷新布局和滚动区域
self.img_container.adjustSize()
self.img_layout.activate()
self.img_scroll.update()
# === 诊断日志:排查缩略图不可见问题 ===
self.logger.info(f"[诊断] img_layout.count = {self.img_layout.count()}")
self.logger.info(f"[诊断] img_container.size = {self.img_container.size().width()}x{self.img_container.size().height()}")
self.logger.info(f"[诊断] img_container.isVisible = {self.img_container.isVisible()}")
self.logger.info(f"[诊断] img_scroll.size = {self.img_scroll.size().width()}x{self.img_scroll.size().height()}")
self.logger.info(f"[诊断] img_scroll.isVisible = {self.img_scroll.isVisible()}")
self.logger.info(f"[诊断] img_scroll.widget = {self.img_scroll.widget()}")
self.logger.info(f"[诊断] img_scroll.widgetResizable = {self.img_scroll.widgetResizable()}")
for i in range(self.img_layout.count()):
item = self.img_layout.itemAt(i)
w = item.widget()
if w:
self.logger.info(
f"[诊断] layout[{i}]: widget={w.__class__.__name__}, "
f"size={w.size().width()}x{w.size().height()}, "
f"sizeHint={w.sizeHint().width()}x{w.sizeHint().height()}, "
f"visible={w.isVisible()}, "
f"geometry={w.geometry()}"
)
# 检查子 widget
for child in w.findChildren(QLabel):
pm = child.pixmap()
self.logger.info(
f"[诊断] QLabel: size={child.size().width()}x{child.size().height()}, "
f"visible={child.isVisible()}, "
f"hasPixmap={pm is not None and not pm.isNull() if pm else False}"
)
else:
self.logger.info(f"[诊断] layout[{i}]: spacer/stretch")
except Exception as e:
self.logger.error(f"更新图片预览失败: {str(e)}", exc_info=True)
......