Skip to content

Commit

Permalink
fix: Limit input printCount range
Browse files Browse the repository at this point in the history
The input printCount might lessthan -1,
cause print behavior error.
Add check, printCount = 0 when input value < -1.

Log: Limit input printCount range
Bug: https://pms.uniontech.com/bug-view-241777.html
  • Loading branch information
rb-union committed Feb 2, 2024
1 parent fe68a31 commit cd195ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libimageviewer/service/permissionconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ static const qreal g_PrintColumnSpacingLimit = 2.0;
// 打印水印默认字体大小,用于计算转换系数
static const qreal g_DefaultPrintFontSize = 65.0;

// 打印计数为-1时,无打印限制
static const int g_UnlimitPrintCount = -1;

/**
@brief 通过dbus接口从任务栏激活窗口
*/
Expand Down Expand Up @@ -188,14 +191,18 @@ bool PermissionConfig::isUnlimitPrint() const
if (checkAuthInvalid()) {
return true;
}
return -1 == printLimitCount;
return g_UnlimitPrintCount == printLimitCount;
}

/**
@brief 减少一次打印计数并发送打印计数变更信号 `printCountChanged`
*/
void PermissionConfig::reduceOnePrintCount()
{
if (g_UnlimitPrintCount == printLimitCount) {
return;
}

if (printLimitCount > 0) {
printLimitCount--;
Q_EMIT printCountChanged();
Expand Down Expand Up @@ -612,6 +619,9 @@ void PermissionConfig::initAuthorise(const QJsonObject &param)
}

printLimitCount = param.value("printCount").toInt(0);
if (printLimitCount < g_UnlimitPrintCount) {
printLimitCount = 0;
}
}

#ifdef DTKWIDGET_CLASS_DWaterMarkHelper
Expand Down

0 comments on commit cd195ac

Please sign in to comment.