From 2bd148dcbaaec79cd20846473f14ee0b6782e0f3 Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Thu, 5 Oct 2023 23:38:57 -0400 Subject: [PATCH 1/2] fix: avoid QFile::readall when loading resources --- src/common/file.cc | 11 +++++------ src/common/file.hh | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/file.cc b/src/common/file.cc index dedbbea8..fefa51f5 100644 --- a/src/common/file.cc +++ b/src/common/file.cc @@ -36,9 +36,9 @@ bool tryPossibleZipName( std::string const & name, std::string & copyTo ) void loadFromFile( std::string const & filename, std::vector< char > & data ) { File::Class f( filename, "rb" ); - QByteArray byteArray{ f.readall() }; - data.reserve( byteArray.size() ); - data = std::vector< char >( byteArray.cbegin(), byteArray.cend() ); + auto size = f.file().size(); // QFile::size() obtains size via statx on Linux + data.resize( size ); + f.read( data.data(), size ); } void Class::open( char const * mode ) @@ -82,10 +82,9 @@ Class::Class( std::string_view filename, char const * mode ) void Class::read( void * buf, qint64 size ) { - qint64 result = f.read( static_cast< char * >( buf ), size ); - - if ( result != size ) + if ( f.read( static_cast< char * >( buf ), size ) != size ) { throw exReadError(); + } } size_t Class::readRecords( void * buf, qint64 size, qint64 count ) diff --git a/src/common/file.hh b/src/common/file.hh index 53c91ae2..c6b08fba 100644 --- a/src/common/file.hh +++ b/src/common/file.hh @@ -13,7 +13,8 @@ #include #include -/// A simple wrapper over QFile with some convenient GD specific functions +/// A wrapper over QFile with some GD specific functions +/// and exception throwing which are required for older coded to work correctly /// Consider the wrapped QFile as private implementation in the `Pimpl Idiom` /// /// Note: this is used *only* in code related to `Dictionary::CLass` to manage dict files. From b0975f02535196a7286f83fb68cc4784379b0078 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 03:59:44 +0000 Subject: [PATCH 2/2] [autofix.ci] apply automated fixes --- src/stylesheets/article-style.css | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/stylesheets/article-style.css b/src/stylesheets/article-style.css index bde27be0..f7852ada 100644 --- a/src/stylesheets/article-style.css +++ b/src/stylesheets/article-style.css @@ -5,18 +5,9 @@ html { } body { - font-family: - -apple-system, - BlinkMacSystemFont, - Tahoma, Verdana, "Lucida Sans Unicode","Palatino Linotype", "Arial Unicode MS", - "Segoe UI", - Roboto, - Oxygen, - Ubuntu, - Cantarell, - "Open Sans", - "Helvetica Neue", - sans-serif; + font-family: -apple-system, BlinkMacSystemFont, Tahoma, Verdana, + "Lucida Sans Unicode", "Palatino Linotype", "Arial Unicode MS", "Segoe UI", + Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; } h1,