From e795b70c7e9dac43c28449f10e93ba636bcaef25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 14 Sep 2023 01:15:46 -0300 Subject: [PATCH] eepp: Updated efsw. Refactored MD5 class. ecode: Updated build.app.sh scripts with the new font assets. Tried to reduce the false positives of the document modified alert (I don't think it worked, needs more investigation). --- include/eepp/scene/node.hpp | 10 +- include/eepp/system/md5.hpp | 36 +++--- include/eepp/ui/doc/textdocument.hpp | 5 + projects/haiku/ecode/build.app.sh | 3 + projects/linux/ecode/build.app.sh | 3 + projects/linux/ee.creator.user | 2 +- projects/macos/ecode/build.app.sh | 3 + projects/mingw32/ecode/build.app.sh | 3 + src/eepp/scene/node.cpp | 18 ++- src/eepp/system/md5.cpp | 159 ++++++++++++------------ src/eepp/ui/doc/textdocument.cpp | 26 ++++ src/eepp/ui/tools/uiwidgetinspector.cpp | 5 +- src/thirdparty/efsw | 2 +- src/tools/ecode/ecode.cpp | 8 ++ src/tools/ecode/filesystemlistener.cpp | 8 +- 15 files changed, 178 insertions(+), 113 deletions(-) diff --git a/include/eepp/scene/node.hpp b/include/eepp/scene/node.hpp index 9a08417ea..cc034519c 100644 --- a/include/eepp/scene/node.hpp +++ b/include/eepp/scene/node.hpp @@ -144,9 +144,9 @@ class EE_API Node : public Transformable { const BlendMode& getBlendMode() const; - void toFront(); + Node* toFront(); - void toBack(); + Node* toBack(); void toPosition( const Uint32& position ); @@ -356,11 +356,11 @@ class EE_API Node : public Transformable { bool reportSizeChangeToChilds() const; - void centerHorizontal(); + Node* centerHorizontal(); - void centerVertical(); + Node* centerVertical(); - void center(); + Node* center(); Node* clipEnable(); diff --git a/include/eepp/system/md5.hpp b/include/eepp/system/md5.hpp index 5a0427309..1cee159dc 100644 --- a/include/eepp/system/md5.hpp +++ b/include/eepp/system/md5.hpp @@ -9,16 +9,25 @@ namespace EE { namespace System { class EE_API MD5 { public: - struct Result { - std::vector digest; + using Digest = std::array; - std::string toHexString() { return MD5::hexDigest( digest ); } + struct Result { + Digest digest; + + std::string toHexString() const { return MD5::hexDigest( digest ); } bool operator==( const Result& other ) { return digest == other.digest; } bool operator!=( const Result& other ) { return digest != other.digest; } }; + struct Context { + Uint32 lo, hi; + Uint32 a, b, c, d; + unsigned char buffer[64]; + Uint32 block[16]; + }; + /** @return Calculates the md5 hash from a stream */ static Result fromStream( IOStream& stream ); @@ -34,25 +43,18 @@ class EE_API MD5 { /** Calculates the md5 hash from a string */ static Result fromString( const String& str ); - protected: - typedef unsigned int MD5_u32plus; + static void init( Context& ctx ); - struct Context { - MD5_u32plus lo, hi; - MD5_u32plus a, b, c, d; - unsigned char buffer[64]; - MD5_u32plus block[16]; - }; + static void update( Context& ctx, const void* data, unsigned long size ); - static const void* body( Context* ctx, const void* data, unsigned long size ); + static void final( Digest& result, Context& ctx ); - static void init( Context* ctx ); + static Result result( Context& ctx ); - static void update( Context* ctx, const void* data, unsigned long size ); + static std::string hexDigest( const Digest& digest ); - static void final( unsigned char* result, Context* ctx ); - - static std::string hexDigest( std::vector& digest ); + private: + static const void* body( Context& ctx, const void* data, unsigned long size ); }; }} // namespace EE::System diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 8c50eb5c7..30de2ef40 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -177,6 +177,10 @@ class EE_API TextDocument { bool hasSelection() const; + const std::array& getHash() const; + + std::string getHashHexString() const; + String getText( const TextRange& range ) const; String getText() const; @@ -590,6 +594,7 @@ class EE_API TextDocument { UndoStack mUndoStack; std::string mFilePath; std::string mLoadingFilePath; + std::array mHash; URI mFileURI; URI mLoadingFileURI; FileInfo mFileRealPath; diff --git a/projects/haiku/ecode/build.app.sh b/projects/haiku/ecode/build.app.sh index 2e21946b0..4749c6974 100755 --- a/projects/haiku/ecode/build.app.sh +++ b/projects/haiku/ecode/build.app.sh @@ -19,6 +19,9 @@ mkdir -p ecode.app/assets/colorschemes mkdir -p ecode.app/assets/fonts cp -r ../../../bin/assets/colorschemes ecode.app/assets/ cp -r ../../../bin/assets/fonts/DejaVuSansMono.ttf ecode.app/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Bold.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Oblique.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-BoldOblique.ttf ecode/assets/fonts/ cp -r ../../../bin/assets/fonts/DejaVuSansMonoNerdFontComplete.ttf ecode.app/assets/fonts/ cp -r ../../../bin/assets/fonts/nonicons.ttf ecode.app/assets/fonts/ cp -r ../../../bin/assets/fonts/codicon.ttf ecode.app/assets/fonts/ diff --git a/projects/linux/ecode/build.app.sh b/projects/linux/ecode/build.app.sh index 83c8da012..7fa05af8b 100755 --- a/projects/linux/ecode/build.app.sh +++ b/projects/linux/ecode/build.app.sh @@ -37,6 +37,9 @@ mkdir -p ecode.app/assets/colorschemes mkdir -p ecode.app/assets/fonts cp -r ../../../bin/assets/colorschemes ecode.app/assets/ cp -r ../../../bin/assets/fonts/DejaVuSansMono.ttf ecode.app/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Bold.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Oblique.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-BoldOblique.ttf ecode/assets/fonts/ cp -r ../../../bin/assets/fonts/DejaVuSansMonoNerdFontComplete.ttf ecode.app/assets/fonts/ cp -r ../../../bin/assets/fonts/nonicons.ttf ecode.app/assets/fonts/ cp -r ../../../bin/assets/fonts/codicon.ttf ecode.app/assets/fonts/ diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 8bbc0fec7..28fe5ddd0 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/projects/macos/ecode/build.app.sh b/projects/macos/ecode/build.app.sh index e9689bf5d..57e2552d3 100755 --- a/projects/macos/ecode/build.app.sh +++ b/projects/macos/ecode/build.app.sh @@ -44,6 +44,9 @@ cp -r ../../../bin/assets/colorschemes/ ecode.app/Contents/MacOS/assets/colorsch #cp -r ../../../bin/assets/fonts ecode.app/Contents/MacOS/assets/ mkdir -p ecode.app/Contents/MacOS/assets/fonts cp -r ../../../bin/assets/fonts/DejaVuSansMono.ttf ecode.app/Contents/MacOS/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Bold.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Oblique.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-BoldOblique.ttf ecode/assets/fonts/ cp -r ../../../bin/assets/fonts/DejaVuSansMonoNerdFontComplete.ttf ecode.app/Contents/MacOS/assets/fonts/ cp -r ../../../bin/assets/fonts/nonicons.ttf ecode.app/Contents/MacOS/assets/fonts/ cp -r ../../../bin/assets/fonts/codicon.ttf ecode.app/Contents/MacOS/assets/fonts/ diff --git a/projects/mingw32/ecode/build.app.sh b/projects/mingw32/ecode/build.app.sh index 47ea51a91..a8075faab 100755 --- a/projects/mingw32/ecode/build.app.sh +++ b/projects/mingw32/ecode/build.app.sh @@ -42,6 +42,9 @@ mkdir -p ecode/assets/colorschemes mkdir -p ecode/assets/fonts cp -r ../../../bin/assets/colorschemes ecode/assets/ cp -r ../../../bin/assets/fonts/DejaVuSansMono.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Bold.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-Oblique.ttf ecode/assets/fonts/ +cp -r ../../../bin/assets/fonts/DejaVuSansMono-BoldOblique.ttf ecode/assets/fonts/ cp -r ../../../bin/assets/fonts/DejaVuSansMonoNerdFontComplete.ttf ecode/assets/fonts/ cp -r ../../../bin/assets/fonts/nonicons.ttf ecode/assets/fonts/ cp -r ../../../bin/assets/fonts/codicon.ttf ecode/assets/fonts/ diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index 99039fca3..89202ef44 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -430,17 +430,19 @@ const BlendMode& Node::getBlendMode() const { return mBlend; } -void Node::toFront() { +Node* Node::toFront() { if ( NULL != mParentNode && mParentNode->mChildLast != this ) { mParentNode->childRemove( this ); mParentNode->childAdd( this ); } + return this; } -void Node::toBack() { +Node* Node::toBack() { if ( NULL != mParentNode ) { mParentNode->childAddAt( this, 0 ); } + return this; } void Node::toPosition( const Uint32& Pos ) { @@ -1658,27 +1660,31 @@ void Node::disableReportSizeChangeToChilds() { writeNodeFlag( NODE_FLAG_REPORT_SIZE_CHANGE_TO_CHILDS, 0 ); } -void Node::centerHorizontal() { +Node* Node::centerHorizontal() { Node* node = getParent(); if ( NULL != node ) { setPosition( eefloor( ( node->getSize().getWidth() - getSize().getWidth() ) * 0.5f ), getPosition().y ); } + return this; } -void Node::centerVertical() { +Node* Node::centerVertical() { Node* node = getParent(); if ( NULL != node ) { setPosition( getPosition().x, eefloor( node->getSize().getHeight() - getSize().getHeight() ) * 0.5f ); } + return this; } -void Node::center() { +Node* Node::center() { Node* node = getParent(); - if ( NULL != node ) + if ( NULL != node ) { setPosition( eefloor( ( node->getSize().getWidth() - getSize().getWidth() ) * 0.5f ), eefloor( node->getSize().getHeight() - getSize().getHeight() ) * 0.5f ); + } + return this; } Node* Node::clipEnable() { diff --git a/src/eepp/system/md5.cpp b/src/eepp/system/md5.cpp index 657f0e7b0..ead62d8a0 100644 --- a/src/eepp/system/md5.cpp +++ b/src/eepp/system/md5.cpp @@ -59,31 +59,30 @@ namespace EE { namespace System { * doesn't work. */ #if defined( __i386__ ) || defined( __x86_64__ ) || defined( __vax__ ) -#define SET( n ) ( *(MD5_u32plus*)&ptr[(n)*4] ) +#define SET( n ) ( *(Uint32*)&ptr[(n)*4] ) #define GET( n ) SET( n ) #else -#define SET( n ) \ - ( ctx->block[( n )] = (MD5_u32plus)ptr[(n)*4] | ( (MD5_u32plus)ptr[(n)*4 + 1] << 8 ) | \ - ( (MD5_u32plus)ptr[(n)*4 + 2] << 16 ) | \ - ( (MD5_u32plus)ptr[(n)*4 + 3] << 24 ) ) -#define GET( n ) ( ctx->block[( n )] ) +#define SET( n ) \ + ( ctx.block[( n )] = (Uint32)ptr[(n)*4] | ( (Uint32)ptr[(n)*4 + 1] << 8 ) | \ + ( (Uint32)ptr[(n)*4 + 2] << 16 ) | ( (Uint32)ptr[(n)*4 + 3] << 24 ) ) +#define GET( n ) ( ctx.block[( n )] ) #endif /* * This processes one or more 64-byte data blocks, but does NOT update * the bit counters. There are no alignment requirements. */ -const void* MD5::body( MD5::Context* ctx, const void* data, unsigned long size ) { +const void* MD5::body( Context& ctx, const void* data, unsigned long size ) { const unsigned char* ptr; - MD5_u32plus a, b, c, d; - MD5_u32plus saved_a, saved_b, saved_c, saved_d; + Uint32 a, b, c, d; + Uint32 saved_a, saved_b, saved_c, saved_d; ptr = (const unsigned char*)data; - a = ctx->a; - b = ctx->b; - c = ctx->c; - d = ctx->d; + a = ctx.a; + b = ctx.b; + c = ctx.c; + d = ctx.d; do { saved_a = a; @@ -171,15 +170,15 @@ const void* MD5::body( MD5::Context* ctx, const void* data, unsigned long size ) ptr += 64; } while ( size -= 64 ); - ctx->a = a; - ctx->b = b; - ctx->c = c; - ctx->d = d; + ctx.a = a; + ctx.b = b; + ctx.c = c; + ctx.d = d; return ptr; } -std::string MD5::hexDigest( std::vector& digest ) { +std::string MD5::hexDigest( const MD5::Digest& digest ) { char buf[33]; size_t size = digest.size(); @@ -191,24 +190,24 @@ std::string MD5::hexDigest( std::vector& digest ) { return std::string( buf ); } -void MD5::init( MD5::Context* ctx ) { - ctx->a = 0x67452301; - ctx->b = 0xefcdab89; - ctx->c = 0x98badcfe; - ctx->d = 0x10325476; +void MD5::init( Context& ctx ) { + ctx.a = 0x67452301; + ctx.b = 0xefcdab89; + ctx.c = 0x98badcfe; + ctx.d = 0x10325476; - ctx->lo = 0; - ctx->hi = 0; + ctx.lo = 0; + ctx.hi = 0; } -void MD5::update( MD5::Context* ctx, const void* data, unsigned long size ) { - MD5_u32plus saved_lo; +void MD5::update( Context& ctx, const void* data, unsigned long size ) { + Uint32 saved_lo; unsigned long used, available; - saved_lo = ctx->lo; - if ( ( ctx->lo = ( saved_lo + size ) & 0x1fffffff ) < saved_lo ) - ctx->hi++; - ctx->hi += size >> 29; + saved_lo = ctx.lo; + if ( ( ctx.lo = ( saved_lo + size ) & 0x1fffffff ) < saved_lo ) + ctx.hi++; + ctx.hi += size >> 29; used = saved_lo & 0x3f; @@ -216,14 +215,14 @@ void MD5::update( MD5::Context* ctx, const void* data, unsigned long size ) { available = 64 - used; if ( size < available ) { - memcpy( &ctx->buffer[used], data, size ); + memcpy( &ctx.buffer[used], data, size ); return; } - memcpy( &ctx->buffer[used], data, available ); + memcpy( &ctx.buffer[used], data, available ); data = (const unsigned char*)data + available; size -= available; - body( ctx, ctx->buffer, 64 ); + body( ctx, ctx.buffer, 64 ); } if ( size >= 64 ) { @@ -231,57 +230,63 @@ void MD5::update( MD5::Context* ctx, const void* data, unsigned long size ) { size &= 0x3f; } - memcpy( ctx->buffer, data, size ); + memcpy( ctx.buffer, data, size ); } -void MD5::final( unsigned char* result, MD5::Context* ctx ) { +void MD5::final( MD5::Digest& result, Context& ctx ) { unsigned long used, available; - used = ctx->lo & 0x3f; + used = ctx.lo & 0x3f; - ctx->buffer[used++] = 0x80; + ctx.buffer[used++] = 0x80; available = 64 - used; if ( available < 8 ) { - memset( &ctx->buffer[used], 0, available ); - body( ctx, ctx->buffer, 64 ); + memset( &ctx.buffer[used], 0, available ); + body( ctx, ctx.buffer, 64 ); used = 0; available = 64; } - memset( &ctx->buffer[used], 0, available - 8 ); + memset( &ctx.buffer[used], 0, available - 8 ); - ctx->lo <<= 3; - ctx->buffer[56] = ctx->lo; - ctx->buffer[57] = ctx->lo >> 8; - ctx->buffer[58] = ctx->lo >> 16; - ctx->buffer[59] = ctx->lo >> 24; - ctx->buffer[60] = ctx->hi; - ctx->buffer[61] = ctx->hi >> 8; - ctx->buffer[62] = ctx->hi >> 16; - ctx->buffer[63] = ctx->hi >> 24; + ctx.lo <<= 3; + ctx.buffer[56] = ctx.lo; + ctx.buffer[57] = ctx.lo >> 8; + ctx.buffer[58] = ctx.lo >> 16; + ctx.buffer[59] = ctx.lo >> 24; + ctx.buffer[60] = ctx.hi; + ctx.buffer[61] = ctx.hi >> 8; + ctx.buffer[62] = ctx.hi >> 16; + ctx.buffer[63] = ctx.hi >> 24; - body( ctx, ctx->buffer, 64 ); + body( ctx, ctx.buffer, 64 ); - result[0] = ctx->a; - result[1] = ctx->a >> 8; - result[2] = ctx->a >> 16; - result[3] = ctx->a >> 24; - result[4] = ctx->b; - result[5] = ctx->b >> 8; - result[6] = ctx->b >> 16; - result[7] = ctx->b >> 24; - result[8] = ctx->c; - result[9] = ctx->c >> 8; - result[10] = ctx->c >> 16; - result[11] = ctx->c >> 24; - result[12] = ctx->d; - result[13] = ctx->d >> 8; - result[14] = ctx->d >> 16; - result[15] = ctx->d >> 24; + result[0] = ctx.a; + result[1] = ctx.a >> 8; + result[2] = ctx.a >> 16; + result[3] = ctx.a >> 24; + result[4] = ctx.b; + result[5] = ctx.b >> 8; + result[6] = ctx.b >> 16; + result[7] = ctx.b >> 24; + result[8] = ctx.c; + result[9] = ctx.c >> 8; + result[10] = ctx.c >> 16; + result[11] = ctx.c >> 24; + result[12] = ctx.d; + result[13] = ctx.d >> 8; + result[14] = ctx.d >> 16; + result[15] = ctx.d >> 24; - memset( ctx, 0, sizeof( *ctx ) ); + memset( &ctx, 0, sizeof( ctx ) ); +} + +MD5::Result MD5::result( Context& ctx ) { + MD5::Digest digest; + final( digest, ctx ); + return { digest }; } MD5::Result MD5::fromStream( IOStream& stream ) { @@ -293,25 +298,23 @@ MD5::Result MD5::fromStream( IOStream& stream ) { stream.seek( 0 ); - init( &ctx ); + init( ctx ); while ( size > 0 ) { if ( size > buff_size ) { stream.read( data, buff_size ); - update( &ctx, data, buff_size ); + update( ctx, data, buff_size ); } else { stream.read( data, size ); - update( &ctx, data, size ); + update( ctx, data, size ); } size -= buff_size; } - res.digest.resize( 16 ); - - final( &res.digest[0], &ctx ); + final( res.digest, ctx ); return res; } @@ -326,13 +329,11 @@ MD5::Result MD5::fromMemory( const Uint8* data, Uint64 size ) { Context ctx; - init( &ctx ); + init( ctx ); - update( &ctx, data, size ); + update( ctx, data, size ); - res.digest.resize( 16 ); - - final( &res.digest[0], &ctx ); + final( res.digest, ctx ); return res; } diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index 45ed5e886..b63b29a03 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,7 @@ bool TextDocument::isUntitledEmpty() const { } void TextDocument::reset() { + mHash = {}; mMightBeBinary = false; mIsBOM = false; mDirtyOnFileSystem = false; @@ -123,6 +125,7 @@ TextDocument::LoadStatus TextDocument::loadFromStream( IOStream& file, std::stri if ( callReset ) reset(); mLines.clear(); + MD5::Context md5Ctx; if ( file.isOpen() ) { const size_t BLOCK_SIZE = EE_1MB; size_t total = file.getSize(); @@ -134,11 +137,15 @@ TextDocument::LoadStatus TextDocument::loadFromStream( IOStream& file, std::stri int consume; char* bufferPtr; TScopedBuffer data( blockSize ); + MD5::init( md5Ctx ); + while ( pending && mLoading ) { read = file.read( data.get(), blockSize ); bufferPtr = data.get(); consume = read; + MD5::update( md5Ctx, data.get(), read ); + if ( pending == total ) { // Check UTF-8 BOM header if ( (char)0xef == data.get()[0] && (char)0xbb == data.get()[1] && @@ -216,7 +223,10 @@ TextDocument::LoadStatus TextDocument::loadFromStream( IOStream& file, std::stri bool wasInterrupted = !mLoading; if ( wasInterrupted ) reset(); + + mHash = MD5::result( md5Ctx ).digest; mLoading = false; + return wasInterrupted ? LoadStatus::Interrupted : ( file.isOpen() ? LoadStatus::Loaded : LoadStatus::Failed ); } @@ -554,9 +564,12 @@ bool TextDocument::save( IOStream& stream, bool keepUndoRedoStatus ) { return false; BoolScopedOp op( mDoingTextInput, true ); const std::string whitespaces( " \t\f\v\n\r" ); + MD5::Context md5Ctx; + MD5::init( md5Ctx ); if ( mIsBOM ) { unsigned char bom[] = { 0xEF, 0xBB, 0xBF }; stream.write( (char*)bom, sizeof( bom ) ); + MD5::update( md5Ctx, bom, sizeof( bom ) ); } size_t lastLine = mLines.size() - 1; for ( size_t i = 0; i <= lastLine; i++ ) { @@ -592,11 +605,14 @@ bool TextDocument::save( IOStream& stream, bool keepUndoRedoStatus ) { text += "\n"; } stream.write( text.c_str(), text.size() ); + MD5::update( md5Ctx, text.data(), text.size() ); } else if ( mLineEnding == LineEnding::CR ) { text[text.size() - 1] = '\r'; stream.write( text.c_str(), text.size() ); + MD5::update( md5Ctx, text.data(), text.size() ); } else { stream.write( text.c_str(), text.size() ); + MD5::update( md5Ctx, text.data(), text.size() ); } } @@ -605,6 +621,8 @@ bool TextDocument::save( IOStream& stream, bool keepUndoRedoStatus ) { if ( !keepUndoRedoStatus ) cleanChangeId(); + mHash = MD5::result( md5Ctx ).digest; + return true; } @@ -801,6 +819,14 @@ bool TextDocument::hasSelection() const { return mSelection.hasSelection(); } +const std::array& TextDocument::getHash() const { + return mHash; +} + +std::string TextDocument::getHashHexString() const { + return MD5::Result{ mHash }.toHexString(); +} + String TextDocument::getText( const TextRange& range ) const { TextRange nrange = sanitizeRange( range.normalized() ); if ( nrange.start().line() == nrange.end().line() ) { diff --git a/src/eepp/ui/tools/uiwidgetinspector.cpp b/src/eepp/ui/tools/uiwidgetinspector.cpp index 772d16cfe..06bba1de5 100644 --- a/src/eepp/ui/tools/uiwidgetinspector.cpp +++ b/src/eepp/ui/tools/uiwidgetinspector.cpp @@ -122,11 +122,12 @@ UIWindow* UIWidgetInspector::create( UISceneNode* sceneNode, const Float& menuIc } ); cont->find( "open-texture-viewer" )->onClick( []( auto ) { - SceneManager::instance()->getUISceneNode()->loadLayoutFromString( R"xml( + auto win = SceneManager::instance()->getUISceneNode()->loadLayoutFromString( R"xml( - )xml" )->center(); + )xml" ); + win->center()->runOnMainThread( [win] { win->toFront(); }, Milliseconds( 1 ) ); } ); uiWin->center(); diff --git a/src/thirdparty/efsw b/src/thirdparty/efsw index bc4eac387..350f0d9f5 160000 --- a/src/thirdparty/efsw +++ b/src/thirdparty/efsw @@ -1 +1 @@ -Subproject commit bc4eac387a09ed75a379a71e05b31f424d146c8a +Subproject commit 350f0d9f5b908e160eb076862af85833d84b9b41 diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 72c8694cd..b43b82a68 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -2067,6 +2067,14 @@ void App::createDocAlert( UICodeEditor* editor ) { editor->setFocus(); } } ); + + docAlert->runOnMainThread( + [docAlert, editor] { + editor->disableReportSizeChangeToChilds(); + docAlert->close(); + editor->setFocus(); + }, + Seconds( 10.f ) ); } void App::loadImageFromMedium( const std::string& path, bool isMemory ) { diff --git a/src/tools/ecode/filesystemlistener.cpp b/src/tools/ecode/filesystemlistener.cpp index 186e7208a..b97bda0d8 100644 --- a/src/tools/ecode/filesystemlistener.cpp +++ b/src/tools/ecode/filesystemlistener.cpp @@ -1,4 +1,5 @@ #include "filesystemlistener.hpp" +#include namespace ecode { @@ -139,8 +140,11 @@ void FileSystemListener::notifyChange( const FileInfo& file ) { mSplitter->forEachDoc( [&]( TextDocument& doc ) { if ( file.getFilepath() == doc.getFileInfo().getFilepath() && file.getModificationTime() != doc.getFileInfo().getModificationTime() && - !doc.isSaving() ) - doc.setDirtyOnFileSystem( true ); + !doc.isSaving() ) { + MD5::Digest curHash = MD5::fromFile( file.getFilepath() ).digest; + if ( curHash != doc.getHash() ) + doc.setDirtyOnFileSystem( true ); + } } ); }