From 9dcb087c07945e34f2918be6d13e45d174155e74 Mon Sep 17 00:00:00 2001 From: captain Date: Tue, 21 Apr 2020 14:06:38 +0800 Subject: [PATCH] Res::get file errors #641 --- .../QLibrary/propertyeditor/QResSelect.cpp | 15 +++++++++------ .../ResPanel/QPreviewHelper/QPreviewHelper.cpp | 16 ++++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/editor/QLibrary/Resources/QLibrary/propertyeditor/QResSelect.cpp b/editor/QLibrary/Resources/QLibrary/propertyeditor/QResSelect.cpp index e6b4fe733..a9ebe24ec 100644 --- a/editor/QLibrary/Resources/QLibrary/propertyeditor/QResSelect.cpp +++ b/editor/QLibrary/Resources/QLibrary/propertyeditor/QResSelect.cpp @@ -113,15 +113,18 @@ namespace QT_UI Echo::String path = val; if (!path.empty()) { - Echo::String fullPath = Echo::IO::instance()->convertResPathToFullPath(path); Echo::String ext = Echo::PathUtil::GetFileExt(path, true); - if (Echo::StringUtil::Equal(ext, ".png", false)) + if (!ext.empty()) { - QPixmap pixmap(fullPath.c_str()); - QRect tRect = QRect(rect.left() + 3, rect.top() + 2, rect.height() - 4, rect.height() - 4); - painter->drawPixmap(tRect, pixmap); + Echo::String fullPath = Echo::IO::instance()->convertResPathToFullPath(path); + if (Echo::StringUtil::Equal(ext, ".png", false)) + { + QPixmap pixmap(fullPath.c_str()); + QRect tRect = QRect(rect.left() + 3, rect.top() + 2, rect.height() - 4, rect.height() - 4); + painter->drawPixmap(tRect, pixmap); - return true; + return true; + } } } diff --git a/editor/echo/Editor/UI/ResPanel/QPreviewHelper/QPreviewHelper.cpp b/editor/echo/Editor/UI/ResPanel/QPreviewHelper/QPreviewHelper.cpp index f770d966d..aa0814d23 100644 --- a/editor/echo/Editor/UI/ResPanel/QPreviewHelper/QPreviewHelper.cpp +++ b/editor/echo/Editor/UI/ResPanel/QPreviewHelper/QPreviewHelper.cpp @@ -164,13 +164,17 @@ namespace QT_UI Echo::String resPath; if (Echo::IO::instance()->convertFullPathToResPath(fullPath, resPath)) { - Echo::ResPtr res = Echo::Res::get(resPath); - if (res && res->getEditor()) + Echo::String extWithDot = Echo::PathUtil::GetFileExt(resPath, true); + if (Echo::Res::getResFunByExtension(extWithDot)) { - icon = res->getEditor()->getThumbnail(); - - if(res->getEditor()->isThumbnailStatic()) - resIconMap[fileExt] = icon; + Echo::ResPtr res = Echo::Res::get(resPath); + if (res && res->getEditor()) + { + icon = res->getEditor()->getThumbnail(); + + if (res->getEditor()->isThumbnailStatic()) + resIconMap[fileExt] = icon; + } } }