Recent Posts

Pages: 1 2 [3] 4 5 6 7 8 ... 10
21
Development / Crash when using with SVG files
« Last post by Miguel Gimenez on October 01, 2022, 09:40:21 am »
I am adapting the code to HiDPI after wx3.1.6 using wxBitmapBundle (see ticket #1297 for details), and I have discovered that wxBitmapBundle::FromSVG() method produces random crashes because the underlying library (nanoSVG) is buggy:
  - first crash is in nsvg_Parse(). This only happens on non-english locales, is fixed in nanoSVG trunk but not in wxWidgets, and a workaround is locale switching before calling FromSVG().
  - second crash is in nsvg__addEdge(). AFAIK this is not fixed and there is no workaround.

Because of this, I will temporarily remove calls to wxBitmapBundle::FromSVG() along this weekend.
22
Plugins development / Re: Code completion using LSP and clangd
« Last post by ollydbg on October 01, 2022, 01:47:51 am »
Since i have seen quite some string encoding related issues in this thread and many try-and-error attempts to solve them, i want to add my two cents to these issues.

Never do this:
Code
wxString contentsValue = contents.at("value").get<std::string>();

This converts the std::string into a wxString using the currently set C++ locale. A locale set in CodeBlocks. But this std::string does not come from CodeBlocks. Also, std::string has, at least on Windows, no support for UTF-8. However, this doesn't stop anyone from putting UTF-8 into such a string. As long as you don't use methods that depend on the locale, this is fine. The code snippet above does depend on the locale.

Now these two lines:
Code
std::string contentsValueStdString = contents.at("value").get<std::string>();
wxString contentsValue(contentsValueStdString.c_str(), wxConvUTF8);

These lines manually convert the std::string to a wxString by telling the wxString object that the std::string does contain UTF-8. Since the user post says this does fix the issue, apparently there is UTF-8 inside that std::string.

I suggest you figure out what encoding Clang does use and then check your code if you rely anywhere else on such automatic conversions. Also, wxWidgets offers the build option wxNO_UNSAFE_WXSTRING_CONV to disable such implicit conversions, but i am not sure if this does also work for std::string, they mention only C-Strings.

Hi, sodev, thanks for the advice.

If I remember correctly, the clangd_client use the UTF-8 format for it's input source. Normally I use UTF-8 for my source code, but my system(Windows) locale is not UTF-8.

I see that clangd's document: Protocol extensions UTF-8 offsets

It said it can support UTF-8.
23
Plugins development / Re: Code completion using LSP and clangd
« Last post by sodev on September 30, 2022, 08:22:14 pm »
Since i have seen quite some string encoding related issues in this thread and many try-and-error attempts to solve them, i want to add my two cents to these issues.

Never do this:
Code
wxString contentsValue = contents.at("value").get<std::string>();

This converts the std::string into a wxString using the currently set C++ locale. A locale set in CodeBlocks. But this std::string does not come from CodeBlocks. Also, std::string has, at least on Windows, no support for UTF-8. However, this doesn't stop anyone from putting UTF-8 into such a string. As long as you don't use methods that depend on the locale, this is fine. The code snippet above does depend on the locale.

Now these two lines:
Code
std::string contentsValueStdString = contents.at("value").get<std::string>();
wxString contentsValue(contentsValueStdString.c_str(), wxConvUTF8);

These lines manually convert the std::string to a wxString by telling the wxString object that the std::string does contain UTF-8. Since the user post says this does fix the issue, apparently there is UTF-8 inside that std::string.

I suggest you figure out what encoding Clang does use and then check your code if you rely anywhere else on such automatic conversions. Also, wxWidgets offers the build option wxNO_UNSAFE_WXSTRING_CONV to disable such implicit conversions, but i am not sure if this does also work for std::string, they mention only C-Strings.
24
Using Code::Blocks / Re: Codebocks for windows
« Last post by sergvnovg on September 30, 2022, 10:21:14 am »
Understood.
A third party software product modifies system variables.
I launch CbLauncher. Everything is working.
Thanks!
25
Plugins development / Re: Code completion using LSP and clangd
« Last post by ollydbg on September 30, 2022, 09:14:17 am »
OK, I think I have fixed this issue by using such patch:

Code
From 8523dd2bd9a58d1780c3d2efe9459f7e5fccfb41 Mon Sep 17 00:00:00 2001
From: hide<hide@hide.hide>
Date: Fri, 30 Sep 2022 15:11:28 +0800
Subject: fix the wrong tip code when Chinese comment is used


diff --git a/clangd_client/src/codecompletion/parser/parser.cpp b/clangd_client/src/codecompletion/parser/parser.cpp
index 2b9c5ea..3ddde25 100644
--- a/clangd_client/src/codecompletion/parser/parser.cpp
+++ b/clangd_client/src/codecompletion/parser/parser.cpp
@@ -2546,7 +2546,8 @@ void Parser::OnLSP_HoverResponse(wxCommandEvent& event, std::vector<ClgdCCToken>
         if (not valueItemsCount) return;
 
         json contents = pJson->at("result").at("contents");
-        wxString contentsValue = contents.at("value").get<std::string>();
+        std::string contentsValueStdString = contents.at("value").get<std::string>();
+        wxString contentsValue(contentsValueStdString.c_str(), wxConvUTF8);
 
         // Example Hover contents: L"instance-method HelloWxWorldFrame::OnAbout\n\nType: void\nParameters:\n- wxCommandEvent & event\n\n// In HelloWxWorldFrame\nprivate: void HelloWxWorldFrame::OnAbout(wxCommandEvent &event)"
         // get string array of hover info separated at /n chars.
@@ -2670,7 +2671,8 @@ void Parser::OnLSP_SignatureHelpResponse(wxCommandEvent& event, std::vector<cbCo
         json signatures = pJson->at("result").at("signatures");
         for (size_t labelndx=0; labelndx<signatureCount && labelndx<10; ++labelndx)
         {
-                wxString labelValue = signatures[labelndx].at("label").get<std::string>();
+                std::string labelValueStdString = signatures[labelndx].at("label").get<std::string>();
+                wxString labelValue(labelValueStdString.c_str(), wxConvUTF8);
                 v_SignatureTokens.push_back(cbCodeCompletionPlugin::CCCallTip(labelValue));
         }
 


I'm not sure the second hunk is needed, but the first hunk is the true fix.
26
Plugins development / Re: Code completion using LSP and clangd
« Last post by ollydbg on September 30, 2022, 08:25:07 am »
I'm not quite understand the code, when I read the source code of clangd_client, I see this:

Code
        size_t resultCount = pJson->at("result").size();
        if (not resultCount) return;

        // Nothing for ShowCalltip is ever in the signature array //(ph 2021/11/1)
        // Show Tootip vs ShowCalltip is so damn confusing !!!
        // **debugging**std::string dumpit = pJson->dump();

        size_t signatureCount = pJson->at("result").at("signatures").size();
        if (not signatureCount) return;

        json signatures = pJson->at("result").at("signatures");
        for (size_t labelndx=0; labelndx<signatureCount && labelndx<10; ++labelndx)
        {
                wxString labelValue = signatures[labelndx].at("label").get<std::string>();
                v_SignatureTokens.push_back(cbCodeCompletionPlugin::CCCallTip(labelValue));
        }

I'm not sure, but it looks like:

Code
wxString labelValue = signatures[labelndx].at("label").get<std::string>();

get<std::string>() should return a std::string.

Do we need to convert it to wxString?
27
Plugins development / Re: Code completion using LSP and clangd
« Last post by ollydbg on September 30, 2022, 07:21:58 am »

What is the variable(s) or name(s) that cause the issue. So that I can try to catch it in the debugger.

Can you give me some code that causes the issue.
So far, I have not been able to re-create the problem.

See a minimal code below:

Code
#include <iostream>
#include <fstream>

using namespace std;

// this file is not used any more?
// std::ofstream txtFile;                                 ///< txt信息
std::ofstream m_TcpFile;                                  ///< TCP接收的数据

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}


My guess is that it is an encoding/decoding error?

Here is the screen shot in attachment.


EDIT

It looks like the comment after the variable definition cause this issue:

Code
///< TCP接收的数据

If I remove this comment, the tooltip showns correctly.


The minimal sample can be simplified to:

Code
int m_TcpFile;  ///< TCP接收的数据

int main()
{
    return 0;
}

28
Plugins development / Re: Code completion using LSP and clangd
« Last post by Pecan on September 30, 2022, 06:15:35 am »
This does not solve the issue.

I had the same problem but setting Direct Write fixed it completely, I'm no longer observing the issue in several days of use....I'm using "Source Code Pro" font and the option "LCD Optimized" but my guess is that the font and optimization doesn't matter

(win7 pro and Win10 Entreprise, latest nightly and latest clangd plugin)

Hi, thanks for the reply.

I just tried it again. I have enabled the Direct Write, and I changed to many kinds of fonts, and the issue still happens.
This also happens when I disable the Direct Write in the Editor option.

The interesting thing is, when the first time I hover the variable, I got this black rectangle(see the attachment). I just tried several times, and the tip messages are all black rectangles, and it start to show a white rectangle about 5 or 6 times later.

Please note that not the all tooltip window has such issue, it only happens on a specify member variables. I guess that the text try to shown in the tip window masses the tip window, but not the other variables' tip message.

What is the variable(s) or name(s) that cause the issue. So that I can try to catch it in the debugger.

Can you give me some code that causes the issue.
So far, I have not been able to re-create the problem.
29
Help / Windows 11 & WSL2 WxSmith black screen & workarround
« Last post by AndrewCot on September 30, 2022, 04:34:02 am »
Over the last few days I have upgraded from Windows 10 to Windows 11 22H2.  I was using WSL2 on Windows 10 with gwsl (X Windows server) for some Linux development. On Windows 11 I do not need the gwsl as it include WSL2 GUI support.

I found that using the WSL2 "standard" Ubuntu 22.04 install C::B wxSmtih shows a total black editor window when loading xrc files. This does not occur on Windows, XUbuntu on VirtualBox or on a Mac using the nightly 12908 release....

On WSL2 if I installed xfce and started the xfce window manager and then loaded C::B the wxSmith black screen did not occur.  So there is a problem with the default WSL2 window manager and wxSmith. Unfortunately I have no idea where to look and as such will leave it for other devs to figure it out.

For info on the WSl2 steps see the following:
https://askubuntu.com/questions/1385703/launch-xfce4-or-other-desktop-in-windows-11-wslg-ubuntu-distro
30
Plugins development / Re: Code completion using LSP and clangd
« Last post by ollydbg on September 30, 2022, 03:31:06 am »
This does not solve the issue.

I had the same problem but setting Direct Write fixed it completely, I'm no longer observing the issue in several days of use....I'm using "Source Code Pro" font and the option "LCD Optimized" but my guess is that the font and optimization doesn't matter

(win7 pro and Win10 Entreprise, latest nightly and latest clangd plugin)

Hi, thanks for the reply.

I just tried it again. I have enabled the Direct Write, and I changed to many kinds of fonts, and the issue still happens.
This also happens when I disable the Direct Write in the Editor option.

The interesting thing is, when the first time I hover the variable, I got this black rectangle(see the attachment). I just tried several times, and the tip messages are all black rectangles, and it start to show a white rectangle about 5 or 6 times later.

Please note that not the all tooltip window has such issue, it only happens on a specify member variables. I guess that the text try to shown in the tip window masses the tip window, but not the other variables' tip message.





Pages: 1 2 [3] 4 5 6 7 8 ... 10