UserOperationLog bug fix(User::Current() can be nullptr)

This commit is contained in:
Krad
2022-01-11 13:04:38 +08:00
parent 969aeb2c56
commit c15fa0e8a9

View File

@@ -65,7 +65,7 @@ void UserOperationLog::log(UserOperation operation, bool processing) {
AppGlobalValues::setLastOperation(operation);
QString operationName = getOperationName(operation);
AppGlobalValues::setInProcessing(processing);
QString UserName = User::Current()->getUserCode().isEmpty()?"anonymous":User::Current()->getUserCode();
QString UserName = (!User::Current() || User::Current()->getUserCode().isEmpty())?"anonymous":User::Current()->getUserCode();
out << now.toString(Qt::DateFormat::ISODateWithMs).replace("T","\t")<<"\t"<<UserName<<"\t"<<operationName<<endl;
}