Code Monkey home page Code Monkey logo

Comments (4)

hexabits avatar hexabits commented on September 2, 2024

(Tip: You can append ?w=1 to the url to remove purely whitespace changes)

Qt Support

NO_CASTs to prevent using deprecated behavior dc21793
Use QT_DISABLE_DEPRECATED_BEFORE 5.2 62778e2
Remove obsolete workaround for Qt 4.4 4efcd8f
Fix Qt warning when opening ColorWheel 22611d0
Switch to QRegularExpression from QRegExp 67ad1f6
Replace remaining QRegExp 0e480c4

Disabling deprecated behavior with macros turns them into compiler errors so that they can be found and replaced. Changes were minimal. First commit involved just using the method Qt already had to return char pointers instead of using a cast. Second commit outright disabled anything deprecated as of 5.2, and the only thing that needed to be changed were the use of Qt algorithms that were deprecated in favor of the standard library.

Build/project

Clean up compiler warnings 4100 and 4189 43b408c
Nifskope.pro C++11, comments for other devs 1db6276
Updated .ts paths, ran lupdate d981f00
Build improvements for MinGW 4d5e1fe
Additional DLLs copied for shared builds 64cd063
Disable compile/analysis warnings for qhull 43ea2e8
Nifskope.pro C++11, comments for other devs 1db6276

Header/Includes

Initial header cleanup 4a59a6f
Explicit includes, move to cpp where possible 79fa8ce
Remove relative includes e1811c9
Remove unnecessary undefs 1a11a72
Missing include for debug builds 5813994

Whitespace

Whitespace changes b198b5f
Whitespace / code style changes Initial e9e5f36

First commit is manual changes I made for the most noticeable indentation issues I happened across. Some were using 3 spaces per indent, some were just a mix of tabs and spaces.

Second commit is automated changes using Uncrustify**. Before running it I spent literally days tweaking the settings and verifying everything went over well. In preparation I had to add brackets to foreach macros because it's not standard C++. It was tripping up on a few files where for example there would be a bracketed if statement inside of a braceless foreach. I don't blame it, since it's a terrible idea to nest something bracketed under something not. Anyway, I did manage to miss a few of these before running it, but the only thing it did was mess up the indentation level on one file (just had to Shift-Tab the code back to the first column). There is virtually no chance that it did anything to affect the integrity of the code, as I set it to make whitespace changes only. There are optional settings to auto-bracket single-line statements (or the opposite) and make if/else chains use consistent bracketing, but I made such changes manually in later commits.

**: I will eventually finish the code style guide and also upload the Uncrustify config file I used.

Code Style (Formatting only)

Fix up all braceless Qt foreach blocks 7d53768
More foreach brackets 662d37a
Remove extraneous semicolons 67b2575
Some manual cleanup, post-auto format e1f40b5
Consistent if/else chains, no mixed braces 7eab8e1
For/foreach no mixing braceless with not 499ef26
Misc cleanup 61afb12
Enum formatting 5b789a2

Aside from the addition of brackets, these changes were mostly aesthetic. The addition of brackets was to prevent future issues and improve the overall integrity of the code. There were some highly questionable if/else chains with a mix of brackets and no brackets. There were single-line if statements separated by comments, or bracketed statements underneath braceless statements. There were multi-nested single line statements, which is just as bad. There was one actual completely braceless if/else chain with one level of nesting (if ( if / else ) else ). There were if/else chains that were all kept on one line per statement (no indentation).

Code Style

Reduce if/else nesting where possible 092712d
Invert conditionals, reduce nesting 1c473a9
More inverts to reduce nesting, general cleanup 98eae83
Static code analysis fixes b1e86a3
Simplification with value(), de-nesting b4a38df
Simplify arg chains when possible fcf42e6

I removed many "if return / else return" idioms. If a scope is guaranteed to return there is no need to nest an else/else if underneath it.

I additionally inverted conditionals where possible to reduce nesting. Take for example:

// Unnecessary nesting

if ( true ) {
    if ( !somethingElse ) {
        // Do this
        doThis();
        doThisOtherThing();

        return true;
    } else {
        return false;
    }
} else {
    return false;
}

// Instead

if ( false )
    return false;

if ( somethingElse )
    return false;

// Do this
doThis();
doThisOtherThing();

return true;

Fixes

Fix a regression with getParent hexabits/nifskope@e8a5925
Fix regression with kfmmodel hexabits/nifskope@4d1275b
Prevent UVWidget crash in Debug builds 75f98f1

These undid a few changes that I made that upon review actually changed the result. I've reviewed the changes multiple times now.

C++11

Uniform Initialization / Initializer Lists cd549b0
Uniform Initialization / Initializer Lists c46034a
Uniform Initialization / Initializer Lists 1bec9bc
Uniform Initialization / Initializer Lists 6c7edd5
Signal/Slot syntax 1 9e98b2b
Signal/Slot syntax 2 7d8242f
Signal/Slot syntax 3 154cfde
nullptr 9436f1a
nullptr bd83b6e
nullptr 4e51809
Range based for 8375e5c
Range based for aa98239

from nifskope.

hexabits avatar hexabits commented on September 2, 2024

I noticed that QRegExp is being superseded by QRegularExpression starting in Qt 5 and I started replacing it where it was used. But I've run into some issues. For one, I'm not sure it worked before. The one place I've dealt with anyway, which is the node culling.

For example if I enter in (ignoring the pipe separators) NiTriShape ... It does not cull NiTriShapes. If I keep with the style and use the ^ i.e. ^NiTriShape it doesn't do anything either. I have tried (non-exhaustively):

Ni
^Ni
Ni*
^Ni*
NiTriShape
^NiTriShape
^NiTriShape$
NiTriShapeData

And so on. And yes, Cull Node by Name is turned on.

In fact, there is another issue going on here. The edit box should be greyed out if it is not checked, but all of my builds post-Qt5 seem to ignore it.** Furthermore it's very slow to type in those fields in my builds, but the old releases are faster.


**It must be an intentional change in 1.1.3 or earlier. I use 1.1.0 as a backup because opening 1.1.3 constantly resets the UI while using dev versions, and the box is greyed out in 1.1.0. Additionally it's commented out in code:

        CullExpr->setToolTip( tr( "Enter a regular expression. Nodes which names match the expression will be hidden" ) );
//    leave RegExp input open as both rendering and collada cull sharing this
//    CullExpr->setEnabled( CullByID->isChecked() );
        CullExpr->setEnabled( true );
        connect( CullExpr, SIGNAL( textChanged( const QString & ) ), this, SIGNAL( sigChanged() ) );
//    connect( CullByID, SIGNAL( toggled( bool ) ), CullExpr, SLOT( setEnabled( bool ) ) );

Ohhhhh. I see the issue here. :) I am considering the node name to be "NiTriShape" etc, when it's really the Name value on the block. Guess that is something to add perhaps.

That still leaves the slowness with that text edit and maybe others. I will look into all the other text edit fields.

from nifskope.

hexabits avatar hexabits commented on September 2, 2024

OK, I narrowed down the slowness to nothing but having Textures enabled (or loaded) across all versions. Even 1.1.0 has sluggish UI elements once I added my texture paths back (<1.1.4 can't autodetect the Skyrim BSAs). When you disable textures, the textbox for Cull Nodes by Name becomes "fast" again.

The presence of textures also makes the other UI elements sluggish, like the Ambient/Diffuse/Specular and Background/Foreground color wheels.

So maybe I can make improvements there so that these elements are more responsive when textures are being rendered.


    connect( Options::get(), SIGNAL( sigChanged() ), textures, SLOT( flush() ) );
    connect( Options::get(), SIGNAL( sigChanged() ), this, SLOT( update() ) );

Narrowed it down to this in glview.cpp (old signal syntax).

Basically, sigChanged might be too vague a signal. Since almost all the options do not need a texture flush.


Fix

Selectively flush textures for large speed up 5487659

from nifskope.

hexabits avatar hexabits commented on September 2, 2024

Updated top comment with all basic code refactoring commits.

Deferred Tasks

  • Clean up comments (formatting, spelling, grammar).

from nifskope.

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.