Giter Site home page Giter Site logo

Comments (12)

rp- avatar rp- commented on May 13, 2024

Hi!

You are right this should be improved and is kinda already stated in the code:

bool SqliteTableModel::isBinary(const QModelIndex& index) const
{
    QByteArray val = m_data.at(index.row()).at(index.column());
    return val.size() > 1024 || val.contains('\0');     // Cheap BLOB test here...
}

We have to improve the isBinary() function

from sqlitebrowser.

rp- avatar rp- commented on May 13, 2024

I also noticed that if you change the type to "TEXT" in the EditDialog, as soon as you edit something it will change back to binary mode, which is a pain and unusable.

from sqlitebrowser.

rp- avatar rp- commented on May 13, 2024

Martin here is a small diff that would fix the 2 issues, any comments?

diff --git a/src/EditDialog.cpp b/src/EditDialog.cpp
index ae1703d..9257151 100644
--- a/src/EditDialog.cpp
+++ b/src/EditDialog.cpp
@@ -141,7 +141,7 @@ void EditDialog::checkDataType()
 {
     // Check if data is text only
     ui->comboEditor->setVisible(true);
-    if(QString(hexEdit->data()).toLatin1() == hexEdit->data())     // Any proper way??
+    if(QString(hexEdit->data()).toUtf8() == hexEdit->data())     // Any proper way??
     {
         ui->editorStack->setCurrentIndex(0);

diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp
index 38b3cda..9ad9499 100644
--- a/src/sqlitetablemodel.cpp
+++ b/src/sqlitetablemodel.cpp
@@ -436,6 +436,6 @@ void SqliteTableModel::clearCache()

 bool SqliteTableModel::isBinary(const QModelIndex& index) const
 {
-    QByteArray val = m_data.at(index.row()).at(index.column());
-    return val.size() > 1024 || val.contains('\0');     // Cheap BLOB test here...
+    QByteArray val = m_data.at(index.row()).at(index.column()).left(1024);
+    return val.contains('\0');     // Cheap BLOB test here...
 }

from sqlitebrowser.

MKleusberg avatar MKleusberg commented on May 13, 2024

Looks good to me. Especially for the isBinary function we might need to come up with an even better version since this function is called quite often and left()+contains() probably isn't the fastest way to check this - but it's definitely an improvement this way!

from sqlitebrowser.

MKleusberg avatar MKleusberg commented on May 13, 2024

Just commited the patch. The problem should be fixed now - thanks Steve for pointing this out!

from sqlitebrowser.

justinclift avatar justinclift commented on May 13, 2024

Should we make a 3.1.1 with this fix in say a week (and whatever else turns up in the meantime)?

from sqlitebrowser.

justinclift avatar justinclift commented on May 13, 2024

Hmmm, thinking about this more, it's a bit iffy to close this without confirmation from the reporter that the problem is solved. It probably is solved, but just in case... 😄

@rp- Your nightly build - non-portable version - will have the fix in it won't it?

If that's the case, @stevehodgett would you be able to test it? Even though it's the non-portable version. http://rp.oldsch00l.com/sqlitebrowser/sqlitebrowser.exe.xz (but wait until tomorrow, when its freshly regenerated)

from sqlitebrowser.

stevehodgett avatar stevehodgett commented on May 13, 2024

Sure, I'll try it tomorrow and let you know.
Quick work!

from sqlitebrowser.

rp- avatar rp- commented on May 13, 2024

yes the build tomorrow should have the fix, if there is no build error.
so before downloading check the file date or build log:
http://rp.oldsch00l.com/sqlitebrowser/

@MKleusberg How did you commit this patch as me? :)

from sqlitebrowser.

stevehodgett avatar stevehodgett commented on May 13, 2024

As predicted, Rene's fix works perfectly as far as I can see both for isBinary and for EditDialog::checkDataType() so, from my perspective, this issue is resolved.
(I do have a related EditDialog comment, but will raise a new issue for it)
Many thanks for the super quick fix!

from sqlitebrowser.

MKleusberg avatar MKleusberg commented on May 13, 2024

@rp- Here is what I did:
git apply yourpatch.diff
git commit -a --author='Peinthor Rene [email protected]'
This leads to a commit where committer!=author just like when applying changes from a foreign repository. Hope you didn't mind 😀

from sqlitebrowser.

rp- avatar rp- commented on May 13, 2024

na it's cool, just thought there is some hidden github button for that :)

from sqlitebrowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.