فهرست منبع

fix 合成时偶现的crash

harry 3 سال پیش
والد
کامیت
9232864c8a
1فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 3 1
      BFFramework/Classes/PQGPUImage/akfilters/PQTextFilter.swift

+ 3 - 1
BFFramework/Classes/PQGPUImage/akfilters/PQTextFilter.swift

@@ -67,7 +67,9 @@ open class PQTextFilter: PQBaseFilter {
                 let size: CGSize = subtitleLab.bounds.size
                 //如果传0,则这个参数会用设备的scale,
                 UIGraphicsBeginImageContextWithOptions(size, false, 2)
-                subtitleLab.layer.render(in: UIGraphicsGetCurrentContext()!)
+                if let context = UIGraphicsGetCurrentContext() {
+                    subtitleLab.layer.render(in: context)
+                }
 
                 self?.subtitleImage = UIGraphicsGetImageFromCurrentImageContext() ?? UIImage()
                 UIGraphicsEndImageContext()