Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:01:44+00:00 2026-06-15T14:01:44+00:00

I have pretty simple application with text entry and button. When user press on

  • 0

I have pretty simple application with text entry and button.

When user press on button , the application downloads file (in other thread) from URL and on success opens dialog message that all done. During downloading i activate spinner (like busy)

enter image description here

Since I don’t know how long will take connect to download file I use separate thread for that purpose. But on “dialog show” my application fails and I get followed error:

(enter_license.exe:210232): Gdk-WARNING **: gdkdrawable-win32.c:1873: GetDC failed: Invalid window handle.

(enter_license.exe:210232): Gdk-WARNING **: gdkgc-win32.c:968: GetCurrentObject failed: The handle is invalid.

(enter_license.exe:210232): Gdk-WARNING **: gdkgc-win32.c:970: RestoreDC failed: The handle is invalid.

(enter_license.exe:210232): Gdk-CRITICAL **: _gdk_win32_drawable_release_dc: assertion `impl->hdc_count > 0' failed

(enter_license.exe:210232): Gdk-WARNING **: gdkwindow-win32.c:2216: SetWindowLongPtr failed: Invalid window handle.

Sounds like something wrong when I try to call GTK object from separate thread.
Maybe somehow I need call handle (callback) to implement “show_dialog” in main thread?

Compile:

 gcc -IC:/MinGW/include -o enter_license enter_license.c  `pkg-config --libs --cflags gtk+-2.0 gthread-2.0``

Flow: main -> call “do_something” -> create thread and call “argument_thread” ->

Here is a snippets of code:

typedef struct _Data
{
 GtkWidget *win; 
 } Data;

main

int main(int argc, char **argv)
{
 GtkWidget *window;

 gtk_init(&argc, &argv);
 window = do_something(NULL, argv);
 g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
 gtk_main();    

return 0;
}

do_something

GtkWidget * do_something(GtkWidget *do_widget, char **argv){
  ....
 GtkWidget *window;

if (!window){
window = gtk_dialog_new_with_buttons ("GtkSpinner",
                                      GTK_WINDOW (do_widget),
                                      0,
                                      GTK_STOCK_CLOSE,
                                      GTK_RESPONSE_NONE,
                                      NULL);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);

g_signal_connect (window, "response", G_CALLBACK (gtk_widget_destroy), NULL);
g_signal_connect (window, "destroy",  G_CALLBACK (gtk_widget_destroyed), &window);


 ....

if (!gtk_widget_get_visible (window)){
 gtk_widget_show_all (window);
}
else{
 gtk_widget_destroy (window);
}

    // define thread
    GThread*  thread;
    GError*   err;  
    Data data;

data.win = window;

     thread = g_thread_create((GThreadFunc)argument_thread,&data,FALSE, &err);
 return window;
}

show_dialog

gboolean show_dialog( GtkWidget* mw)
{
 GtkWidget *dialog;

  printf("BOO: \n");

  // here all works fine
  sleep(3000);
  gtk_widget_show(spinner_sensitive);
  gtk_spinner_start (GTK_SPINNER (spinner_sensitive));
  sleep(3000);
  gtk_spinner_stop (GTK_SPINNER (spinner_sensitive));
  sleep(3000);
  gtk_widget_hide(spinner_sensitive);

  printf("BOO\n");
  // here dialog is shown for 1-10 milisec and get error.

     dialog = gtk_message_dialog_new (GTK_WINDOW(mw),
                     GTK_DIALOG_DESTROY_WITH_PARENT,
                     GTK_MESSAGE_INFO,
                     GTK_BUTTONS_CLOSE,
                     "Downloaded successfully");

             g_signal_connect_swapped (G_OBJECT (dialog), "response",
                     G_CALLBACK (gtk_widget_destroy),
                     G_OBJECT (dialog));
             gtk_widget_show(dialog);
printf("BOO\n");

}

argument_thread

void *argument_thread( gpointer ptr ) {
  Data *data = (Data*)ptr;
gdk_threads_enter();
 show_dialog (data->win);
 gdk_threads_leave();
  return( NULL );
}

Please help me,

Any and all suggestions would be greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:01:45+00:00Added an answer on June 15, 2026 at 2:01 pm

    GTK is not thread-safe so anything that interacts with the GUI will have to run on the main thread.

    Use the g_idle_add function to notify your main thread when the download has finished.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple Linq to XML query: var q = from c
I have a pretty simple block of C# code here... static void ReadMSOfficeWordFile(string file)
I am pretty new to WPF. I have developed a simple application using WPF.
I have implemented pretty simple application, using gwt and gwt event service 1.1.1, it
I have a simple text file, that has following content word1 word2 I need
I have a pretty simple WPF application that is used to format inputs into
I have a pretty simple set up for a messaging application. I simply get
I have pretty simple jquery code : $(document).ready(function(){ $('img.marqFl').on({ mouseenter: function() { $(this).animate({height: 300},
i have pretty simple simple question (i hope so). How do i change the
I have a pretty simple trigger: CREATE OR REPLACE FUNCTION f_log_datei() RETURNS TRIGGER AS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.